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