| Total Complexity | 4 |
| Total Lines | 73 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | abstract class AbstractNetworksCollection |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var AbstractNetwork[] |
||
| 16 | */ |
||
| 17 | protected $networks; |
||
| 18 | |||
| 19 | /** @var Command */ |
||
| 20 | protected $command; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param string $output |
||
| 24 | * |
||
| 25 | * @return array |
||
| 26 | */ |
||
| 27 | abstract protected function extractingNetworks(string $output): array; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @return AbstractNetwork |
||
| 31 | */ |
||
| 32 | abstract protected function getNetwork(): AbstractNetwork; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | abstract protected function getCommand(): string; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * AbstractNetworksCollection constructor. |
||
| 41 | * |
||
| 42 | * @param Command $command |
||
| 43 | */ |
||
| 44 | public function __construct(Command $command) |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @throws Exception |
||
| 51 | * |
||
| 52 | * @return Collection |
||
| 53 | */ |
||
| 54 | public function scan(): Collection |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @param array $networks |
||
| 67 | * |
||
| 68 | * @return void |
||
| 69 | */ |
||
| 70 | protected function setNetworks(array $networks): void |
||
| 71 | { |
||
| 72 | $this->networks = array_map(function (array $network) { |
||
| 73 | return $this->getNetwork()->createFromArray($network); |
||
| 74 | }, $networks); |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @param string $networksString |
||
| 79 | * |
||
| 80 | * @return array |
||
| 81 | */ |
||
| 82 | protected function explodeAvailableNetworks(string $networksString): array |
||
| 85 | } |
||
| 86 | } |
||
| 87 |