Created
August 10, 2020 10:12
-
-
Save hypertensy/018289c0a598d7edeaccf18d8734b7e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Warface; | |
use Warface\Exceptions\WarfaceExceptions; | |
use Warface\Exceptions\WarfaceExceptionsCode; | |
use Warface\Exceptions\WarfaceExceptionsMsg; | |
class ApiClient | |
{ | |
private RequestController $controller; | |
/** | |
* ApiClient constructor. | |
* @param string $region | |
*/ | |
public function __construct(string $region = RequestController::REGION_RU) | |
{ | |
$this->controller = new RequestController($region); | |
} | |
/** | |
* @param $methodName | |
* @param $arguments | |
* @return mixed | |
* @throws WarfaceExceptions | |
*/ | |
public function __call($methodName, $arguments) | |
{ | |
$class = __NAMESPACE__ . "\Methods\\" . ucfirst($methodName); | |
if (!class_exists($class)) { | |
throw new WarfaceExceptions(WarfaceExceptionsMsg::MSG_BRANCH_METHOD_NOT_FOUND, WarfaceExceptionsCode::CODE_REQUEST_NOT_FOUND); | |
} | |
return new $class($this->controller); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment