Total Complexity | 4 |
Total Lines | 79 |
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 string |
||
31 | */ |
||
32 | abstract protected function getNetwork():? string; |
||
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 call_user_func_array([ |
||
74 | $this->getNetwork(), |
||
75 | 'createFromArray', |
||
76 | ], [ |
||
77 | $network, |
||
78 | $this->command, |
||
79 | ]); |
||
80 | }, $networks); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @param string $networksString |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | protected function explodeAvailableNetworks(string $networksString): array |
||
91 | } |
||
92 | } |
||
93 |