Total Complexity | 8 |
Total Lines | 137 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | abstract class AbstractNetwork |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | public $bssid; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | public $ssid; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | */ |
||
25 | public $channel; |
||
26 | |||
27 | /** |
||
28 | * @var float |
||
29 | */ |
||
30 | public $quality; |
||
31 | |||
32 | /** |
||
33 | * @var float |
||
34 | */ |
||
35 | public $dbm; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | public $security; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | public $securityFlags; |
||
46 | |||
47 | /** |
||
48 | * @var int |
||
49 | */ |
||
50 | public $frequency; |
||
51 | |||
52 | /** |
||
53 | * @var bool |
||
54 | */ |
||
55 | public $connected; |
||
56 | |||
57 | /** |
||
58 | * @var array |
||
59 | */ |
||
60 | protected static $securityTypes = [ |
||
61 | 'WPA2', |
||
62 | 'WPA', |
||
63 | 'WEP', |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * @param string $password |
||
68 | * @param string $device |
||
69 | */ |
||
70 | abstract public function connect(string $password, string $device): void; |
||
71 | |||
72 | /** |
||
73 | * @param string $device |
||
74 | */ |
||
75 | abstract public function disconnect(string $device): void; |
||
76 | |||
77 | /** |
||
78 | * @param array $network |
||
79 | * |
||
80 | * @return AbstractNetwork |
||
81 | */ |
||
82 | abstract public static function createFromArray(array $network): self; |
||
83 | |||
84 | /** |
||
85 | * @return string |
||
86 | */ |
||
87 | public function getSecurityType(): string |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @return int |
||
102 | */ |
||
103 | public function getFrequency(): int |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * @return string |
||
110 | */ |
||
111 | public function __toString(): string |
||
112 | { |
||
113 | return implode('|', [ |
||
114 | $this->bssid, |
||
115 | $this->ssid, |
||
116 | $this->quality, |
||
117 | $this->dbm, |
||
118 | $this->security, |
||
119 | $this->securityFlags, |
||
120 | $this->frequency, |
||
121 | var_export($this->connected, true), |
||
122 | ]); |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * @return FrequencyGenerator |
||
127 | */ |
||
128 | protected function getFrequencyGenerator(): FrequencyGenerator |
||
129 | { |
||
130 | return new FrequencyGenerator(); |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * @return float |
||
135 | */ |
||
136 | protected function dBmToQuality(): float |
||
137 | { |
||
138 | return 2 * ($this->dbm + 100); |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * @return float |
||
143 | */ |
||
144 | protected function qualityToDBm(): float |
||
147 | } |
||
148 | } |
||
149 |