| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 11 | public function __call($name, $args = null) |
|
| 35 | { |
||
| 36 | |||
| 37 | 11 | $class = '\\' . (new \ReflectionClass($this))->getNamespaceName() . '\\' . ucfirst($name); |
|
| 38 | 11 | if (!class_exists($class)) { |
|
| 39 | 1 | throw new \InvalidArgumentException("Request $name does not exist"); |
|
| 40 | } |
||
| 41 | |||
| 42 | 10 | if (!(new \ReflectionClass($class))->implementsInterface(ApiRequestInterface::class)) { |
|
| 43 | 1 | throw new \InvalidArgumentException("Request $name is not a valid request"); |
|
| 44 | } |
||
| 45 | |||
| 46 | 9 | $instance = new $class($this->configuration, $this->client); |
|
| 47 | |||
| 48 | 9 | return $instance; |
|
| 49 | } |
||
| 51 |