@@ -89,7 +89,7 @@ |
||
89 | 89 | */ |
90 | 90 | public function hasInfo(): bool |
91 | 91 | { |
92 | - return ! is_null($this->info); |
|
92 | + return !is_null($this->info); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -49,5 +49,5 @@ |
||
49 | 49 | * |
50 | 50 | * @author duc <[email protected]> |
51 | 51 | */ |
52 | - public function getErrors(): array ; |
|
52 | + public function getErrors(): array; |
|
53 | 53 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! function_exists('toUnderScore')) { |
|
3 | +if (!function_exists('toUnderScore')) { |
|
4 | 4 | /** |
5 | 5 | * @param $str |
6 | 6 | * @return string |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | function toUnderScore($str) |
11 | 11 | { |
12 | - $result = preg_replace_callback('/([A-Z]+)/', function ($matches) { |
|
12 | + $result = preg_replace_callback('/([A-Z]+)/', function($matches) { |
|
13 | 13 | return '_' . strtolower($matches[0]); |
14 | 14 | }, $str); |
15 | 15 |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | { |
65 | 65 | $b = preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $ip); |
66 | 66 | |
67 | - if (! $b) { |
|
67 | + if (!$b) { |
|
68 | 68 | throw new InvalidIpAddress; |
69 | 69 | } |
70 | 70 | } |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | { |
96 | 96 | $response = $this->getOriginalInfo(); |
97 | 97 | |
98 | - if (! $response['success']) { |
|
98 | + if (!$response['success']) { |
|
99 | 99 | return (new NullDataMapper())->setInfo(['ip' => $this->getIp()]); |
100 | 100 | } |
101 | 101 | |
102 | - if (! $this->dataMapper) { |
|
102 | + if (!$this->dataMapper) { |
|
103 | 103 | $this->dataMapper = new DataMapper(); |
104 | 104 | |
105 | 105 | return $this->dataMapper->setInfo($response); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function getRequestHandler() |
117 | 117 | { |
118 | - if (! $this->requestHandler) { |
|
118 | + if (!$this->requestHandler) { |
|
119 | 119 | return $this->requestHandler = new RequestHandler(); |
120 | 120 | } |
121 | 121 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function getIp() |
163 | 163 | { |
164 | - if (! $this->ip) { |
|
164 | + if (!$this->ip) { |
|
165 | 165 | throw new \Exception('请先设置 ip'); |
166 | 166 | } |
167 | 167 |
@@ -112,7 +112,7 @@ |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - if (! empty($this->errorStacks)) { |
|
115 | + if (!empty($this->errorStacks)) { |
|
116 | 116 | throw new \RuntimeException(json_encode($this->errorStacks)); |
117 | 117 | } |
118 | 118 |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected function getClosure(string $provider, $concrete = null) |
56 | 56 | { |
57 | - return function () use ($provider, $concrete) { |
|
57 | + return function() use ($provider, $concrete) { |
|
58 | 58 | return $this->createProvider($provider, $concrete); |
59 | 59 | }; |
60 | 60 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | protected function createProvider(string $provider, $concrete) |
72 | 72 | { |
73 | 73 | if (is_object($concrete)) { |
74 | - if (! $concrete instanceof IpImp) { |
|
74 | + if (!$concrete instanceof IpImp) { |
|
75 | 75 | $class = get_class($concrete); |
76 | 76 | throw new IncorrectInstanceException("{$class} is not instanceof " . IpImp::class); |
77 | 77 | } |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | |
84 | 84 | $class = $concrete ?: "\DucCnzj\Ip\Strategies\\{$shortName}"; |
85 | 85 | |
86 | - if (! class_exists($class)) { |
|
86 | + if (!class_exists($class)) { |
|
87 | 87 | throw new IpProviderClassNotExistException("{$class} 不存在"); |
88 | 88 | } |
89 | 89 | |
90 | - if (! (new \ReflectionClass($class))->implementsInterface(IpImp::class)) { |
|
90 | + if (!(new \ReflectionClass($class))->implementsInterface(IpImp::class)) { |
|
91 | 91 | throw new IncorrectInstanceException("{$class} is not instanceof " . IpImp::class); |
92 | 92 | } |
93 | 93 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | $providerClosures = []; |
108 | 108 | |
109 | 109 | foreach ($this->getProviders() as $provider) { |
110 | - if (! $this->shouldNotSkip($provider)) { |
|
110 | + if (!$this->shouldNotSkip($provider)) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
114 | - if (! isset($this->bindings[$provider])) { |
|
114 | + if (!isset($this->bindings[$provider])) { |
|
115 | 115 | $this->bindings[$provider] = $this->getClosure($provider); |
116 | 116 | } |
117 | 117 | |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | public function shouldNotSkip($provider): bool |
170 | 170 | { |
171 | 171 | if (isset($this->withConfigurations[$provider])) { |
172 | - if (! $this->withConfigurations[$provider] || ! ! $this->getProviderConfig($provider)) { |
|
172 | + if (!$this->withConfigurations[$provider] || !!$this->getProviderConfig($provider)) { |
|
173 | 173 | return true; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - return ! ! $this->getProviderConfig($provider); |
|
177 | + return !!$this->getProviderConfig($provider); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function getProviderConfig(string $provider) |
216 | 216 | { |
217 | - if (! isset($this->providerConfig[$provider])) { |
|
217 | + if (!isset($this->providerConfig[$provider])) { |
|
218 | 218 | return []; |
219 | 219 | } |
220 | 220 |