@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | protected function trimArrayValue(array $array): array |
| 17 | 17 | { |
| 18 | - array_walk($array, function (&$item) { |
|
| 18 | + array_walk($array, function(&$item) { |
|
| 19 | 19 | list($firstElement) = $item; |
| 20 | 20 | |
| 21 | 21 | $item = trim($firstElement); |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | protected function getCommand(): string |
| 35 | 35 | { |
| 36 | 36 | return implode(' && ', [ |
| 37 | - $this->getUtility().' -s', |
|
| 38 | - 'echo "'.$this->separator.'"', |
|
| 39 | - $this->getUtility().' --getinfo', |
|
| 37 | + $this->getUtility() . ' -s', |
|
| 38 | + 'echo "' . $this->separator . '"', |
|
| 39 | + $this->getUtility() . ' --getinfo', |
|
| 40 | 40 | ]); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @return string |
| 45 | 45 | */ |
| 46 | - protected function getNetwork():? string |
|
| 46 | + protected function getNetwork(): ? string |
|
| 47 | 47 | { |
| 48 | 48 | return Network::class; |
| 49 | 49 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | array_shift($availableNetworks); |
| 65 | 65 | |
| 66 | - array_walk($availableNetworks, function (&$networkData) use ($currentBssid) { |
|
| 66 | + array_walk($availableNetworks, function(&$networkData) use ($currentBssid) { |
|
| 67 | 67 | $networkData = $this->extractingDataFromString($networkData); |
| 68 | 68 | |
| 69 | 69 | if ($this->isConnected($networkData[self::BSSID_KEY], $currentBssid)) { |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | $extractedProperties = []; |
| 85 | 85 | |
| 86 | - $pattern = '/(.*?)'. |
|
| 87 | - '(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})\s{1,}'. |
|
| 88 | - '([-+]?[0-9]*)\s{1,}'. |
|
| 89 | - '([^a-zA-Z]*)'. |
|
| 90 | - '(\w{1,})\s{1,}'. |
|
| 91 | - '([\w-]+)'. |
|
| 86 | + $pattern = '/(.*?)' . |
|
| 87 | + '(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})\s{1,}' . |
|
| 88 | + '([-+]?[0-9]*)\s{1,}' . |
|
| 89 | + '([^a-zA-Z]*)' . |
|
| 90 | + '(\w{1,})\s{1,}' . |
|
| 91 | + '([\w-]+)' . |
|
| 92 | 92 | '(.*)/'; |
| 93 | 93 | |
| 94 | 94 | preg_match_all( |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | public function connect(string $password, string $device): void |
| 25 | 25 | { |
| 26 | 26 | Command::exec( |
| 27 | - sprintf($this->getUtility().' -setairportnetwork %s %s %s', $device, $this->ssid, $password) |
|
| 27 | + sprintf($this->getUtility() . ' -setairportnetwork %s %s %s', $device, $this->ssid, $password) |
|
| 28 | 28 | ); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | Command::exec( |
| 39 | 39 | implode(' && ', [ |
| 40 | - sprintf($this->getUtility().' -removepreferredwirelessnetwork %s %s', $device, $this->ssid), |
|
| 41 | - sprintf($this->getUtility().' -setairportpower %s %s', $device, 'off'), |
|
| 42 | - sprintf($this->getUtility().' -setairportpower %s %s', $device, 'on'), |
|
| 40 | + sprintf($this->getUtility() . ' -removepreferredwirelessnetwork %s %s', $device, $this->ssid), |
|
| 41 | + sprintf($this->getUtility() . ' -setairportpower %s %s', $device, 'off'), |
|
| 42 | + sprintf($this->getUtility() . ' -setairportpower %s %s', $device, 'on'), |
|
| 43 | 43 | ]) |
| 44 | 44 | ); |
| 45 | 45 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $instance = new self(); |
| 55 | 55 | $instance->ssid = $network[0]; |
| 56 | 56 | $instance->bssid = $network[1]; |
| 57 | - $instance->channel = (int) $network[3]; |
|
| 57 | + $instance->channel = (int)$network[3]; |
|
| 58 | 58 | $instance->security = $network[6]; |
| 59 | 59 | $instance->securityFlags = $network[5]; |
| 60 | 60 | $instance->quality = $network[2]; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @return string |
| 30 | 30 | */ |
| 31 | - abstract protected function getNetwork():? string; |
|
| 31 | + abstract protected function getNetwork(): ? string; |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * @return string |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function scan(): self |
| 44 | 44 | { |
| 45 | - $output = (string) Command::exec($this->getCommand()); |
|
| 45 | + $output = (string)Command::exec($this->getCommand()); |
|
| 46 | 46 | |
| 47 | 47 | return $this->setNetworks( |
| 48 | 48 | $this->extractingNetworks($output) |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getConnected(): array |
| 64 | 64 | { |
| 65 | - return $this->getFiltered(function (AbstractNetwork $network) { |
|
| 65 | + return $this->getFiltered(function(AbstractNetwork $network) { |
|
| 66 | 66 | if ($network->connected) { |
| 67 | 67 | return $network; |
| 68 | 68 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function getBySsid(string $ssid): array |
| 78 | 78 | { |
| 79 | - return $this->getFiltered(function (AbstractNetwork $network) use ($ssid) { |
|
| 79 | + return $this->getFiltered(function(AbstractNetwork $network) use ($ssid) { |
|
| 80 | 80 | if ($network->ssid == $ssid) { |
| 81 | 81 | return $network; |
| 82 | 82 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function getByBssid(string $bssid): array |
| 92 | 92 | { |
| 93 | - return $this->getFiltered(function (AbstractNetwork $network) use ($bssid) { |
|
| 93 | + return $this->getFiltered(function(AbstractNetwork $network) use ($bssid) { |
|
| 94 | 94 | if ($network->bssid == $bssid) { |
| 95 | 95 | return $network; |
| 96 | 96 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | protected function setNetworks(array $networks): self |
| 106 | 106 | { |
| 107 | - $this->networks = array_map(function ($network) { |
|
| 107 | + $this->networks = array_map(function($network) { |
|
| 108 | 108 | /** @var AbstractNetwork $networkInstance */ |
| 109 | 109 | $networkInstance = $this->getNetwork(); |
| 110 | 110 | |
@@ -25,25 +25,25 @@ discard block |
||
| 25 | 25 | protected function getCommand(): string |
| 26 | 26 | { |
| 27 | 27 | $options = |
| 28 | - ' --terse'. |
|
| 29 | - ' --fields '. |
|
| 30 | - 'active,ssid,bssid,'. |
|
| 31 | - 'mode,chan,freq,'. |
|
| 32 | - 'signal,security,wpa-flags,'. |
|
| 33 | - 'rsn-flags'. |
|
| 34 | - ' device'. |
|
| 35 | - ' wifi'. |
|
| 28 | + ' --terse' . |
|
| 29 | + ' --fields ' . |
|
| 30 | + 'active,ssid,bssid,' . |
|
| 31 | + 'mode,chan,freq,' . |
|
| 32 | + 'signal,security,wpa-flags,' . |
|
| 33 | + 'rsn-flags' . |
|
| 34 | + ' device' . |
|
| 35 | + ' wifi' . |
|
| 36 | 36 | ' list'; |
| 37 | 37 | |
| 38 | 38 | return implode(' && ', [ |
| 39 | - $this->getUtility().$options, |
|
| 39 | + $this->getUtility() . $options, |
|
| 40 | 40 | ]); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @return string |
| 45 | 45 | */ |
| 46 | - protected function getNetwork():? string |
|
| 46 | + protected function getNetwork(): ? string |
|
| 47 | 47 | { |
| 48 | 48 | return Network::class; |
| 49 | 49 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $availableNetworks = $this->explodeAvailableNetworks($output); |
| 59 | 59 | |
| 60 | - array_walk($availableNetworks, function (&$networkData) { |
|
| 60 | + array_walk($availableNetworks, function(&$networkData) { |
|
| 61 | 61 | $networkData = $this->extractingDataFromString($networkData); |
| 62 | 62 | }); |
| 63 | 63 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | Command::exec( |
| 33 | 33 | sprintf( |
| 34 | - $this->getUtility().' -w 10 device wifi connect "%s" password "%s" ifname "%s"', |
|
| 34 | + $this->getUtility() . ' -w 10 device wifi connect "%s" password "%s" ifname "%s"', |
|
| 35 | 35 | $this->ssid, |
| 36 | 36 | $password, |
| 37 | 37 | $device |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | Command::exec( |
| 50 | 50 | implode(' && ', [ |
| 51 | - sprintf($this->getUtility().' device disconnect %s', $device), |
|
| 51 | + sprintf($this->getUtility() . ' device disconnect %s', $device), |
|
| 52 | 52 | ]) |
| 53 | 53 | ); |
| 54 | 54 | } |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | $instance = new self(); |
| 64 | 64 | $instance->ssid = $network[1]; |
| 65 | 65 | $instance->bssid = $network[2]; |
| 66 | - $instance->channel = (int) $network[4]; |
|
| 66 | + $instance->channel = (int)$network[4]; |
|
| 67 | 67 | $instance->security = $network[7]; |
| 68 | - $instance->securityFlags = $network[8].' '.$network[9]; |
|
| 68 | + $instance->securityFlags = $network[8] . ' ' . $network[9]; |
|
| 69 | 69 | $instance->dbm = $network[6]; |
| 70 | 70 | $instance->quality = $instance->dBmToQuality(); |
| 71 | - $instance->frequency = (int) $network[5]; |
|
| 71 | + $instance->frequency = (int)$network[5]; |
|
| 72 | 72 | $instance->connected = ($network[0] == self::POSITIVE_CONNECTION_FLAG); |
| 73 | 73 | |
| 74 | 74 | return $instance; |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | Command::exec( |
| 30 | 30 | implode(' && ', [ |
| 31 | 31 | sprintf( |
| 32 | - ($this->getUtility().' add profile filename="%s"'), |
|
| 32 | + ($this->getUtility() . ' add profile filename="%s"'), |
|
| 33 | 33 | $this->getProfileService()->getTmpProfileFileName() |
| 34 | 34 | ), |
| 35 | 35 | sprintf( |
| 36 | - ($this->getUtility().' connect interface="%s" ssid="%s" name="%s"'), |
|
| 36 | + ($this->getUtility() . ' connect interface="%s" ssid="%s" name="%s"'), |
|
| 37 | 37 | $device, |
| 38 | 38 | $this->ssid, |
| 39 | 39 | $this->ssid |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public function disconnect(string $device): void |
| 53 | 53 | { |
| 54 | 54 | Command::exec( |
| 55 | - sprintf($this->getUtility().' disconnect interface="%s"', $device) |
|
| 55 | + sprintf($this->getUtility() . ' disconnect interface="%s"', $device) |
|
| 56 | 56 | ); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $instance->channel = $network[7]; |
| 70 | 70 | $instance->security = $network[2]; |
| 71 | 71 | $instance->securityFlags = $network[3]; |
| 72 | - $instance->quality = (int) $network[5]; |
|
| 72 | + $instance->quality = (int)$network[5]; |
|
| 73 | 73 | $instance->frequency = $instance->getFrequency(); |
| 74 | 74 | $instance->dbm = $instance->qualityToDBm(); |
| 75 | 75 | $instance->connected = isset($network[10]); |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | $hex = ''; |
| 114 | 114 | |
| 115 | 115 | for ($i = 0; $i < $len; $i++) { |
| 116 | - $hex .= substr('0'.dechex(ord($ssid[$i])), -2); |
|
| 116 | + $hex .= substr('0' . dechex(ord($ssid[$i])), -2); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | return strtoupper($hex); |