| Total Complexity | 4 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | class Client implements ServiceFactoryInterface |
||
| 16 | { |
||
| 17 | private RequestFactoryInterface $requestFactory; |
||
|
|
|||
| 18 | private ClientInterface $httpClient; |
||
| 19 | private CredentialsInterface $credentials; |
||
| 20 | |||
| 21 | public function __construct( |
||
| 27 | } |
||
| 28 | |||
| 29 | public function getService(string $serviceName): Service |
||
| 30 | { |
||
| 31 | $serviceClass = __NAMESPACE__ . '\\Services\\' . ucfirst($serviceName); |
||
| 32 | |||
| 33 | if (!class_exists($serviceClass)) { |
||
| 34 | throw new \Promopult\Dadata\Exceptions\ServiceNotFoundException( |
||
| 35 | "Service with {$serviceName} is not found." |
||
| 36 | ); |
||
| 37 | } |
||
| 38 | |||
| 39 | return new $serviceClass( |
||
| 40 | $this->credentials, |
||
| 41 | $this->httpClient |
||
| 42 | ); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function __get($name): Service |
||
| 48 | } |
||
| 49 | } |
||
| 50 |