| Total Complexity | 11 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 33.33% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class TransportFactory implements TransportFactoryInterface |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var TransportFactoryInterface[] |
||
| 11 | */ |
||
| 12 | private iterable $factories; |
||
| 13 | |||
| 14 | public function __construct(iterable $factories) |
||
| 15 | { |
||
| 16 | $this->factories = $factories; |
||
|
|
|||
| 17 | } |
||
| 18 | 1 | ||
| 19 | public function supports(string $dsn): bool |
||
| 20 | 1 | { |
|
| 21 | 1 | foreach ($this->getFactories() as $factory) { |
|
| 22 | if ($factory->supports($dsn)) { |
||
| 23 | 1 | return true; |
|
| 24 | } |
||
| 25 | 1 | } |
|
| 26 | |||
| 27 | return false; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function create(string $dsn): PromiseInterface |
||
| 31 | 1 | { |
|
| 32 | foreach ($this->getFactories() as $factory) { |
||
| 33 | if (!$factory->supports($dsn)) { |
||
| 34 | continue; |
||
| 35 | } |
||
| 36 | |||
| 37 | return $factory->create($dsn); |
||
| 38 | } |
||
| 39 | |||
| 40 | throw new \RuntimeException(\sprintf('Invalid transport DSN %s', $dsn)); |
||
| 41 | } |
||
| 42 | |||
| 43 | private function getFactories(): array |
||
| 57 | } |
||
| 58 | } |
||
| 59 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..