| Total Complexity | 3 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Coverage | 88.89% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class SocialFactory |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Create a new instance of social adapter |
||
| 14 | * |
||
| 15 | * @param string $name $name |
||
| 16 | * @param array $config |
||
| 17 | * @return SocialAdapter |
||
| 18 | */ |
||
| 19 | 2 | public function create(string $name, array $config){ |
|
| 20 | 2 | $class = $this->getAdapterClassname($name); |
|
| 21 | 2 | if (!class_exists($class)) { |
|
| 22 | throw new \RuntimeException("Class '$class' not found"); |
||
| 23 | } |
||
| 24 | 2 | return new $class($config); |
|
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param string $name adapter name |
||
| 29 | * @return string PSR-0 classpath |
||
| 30 | */ |
||
| 31 | 2 | private function getAdapterClassname(string $name){ |
|
| 36 | } |
||
| 37 | } |