@@ -68,12 +68,12 @@ |
||
68 | 68 | $range .= '/32'; |
69 | 69 | } |
70 | 70 | // $range is in IP/CIDR format eg 127.0.0.1/24 |
71 | - list( $range, $netmask ) = explode('/', $range, 2); |
|
71 | + list($range, $netmask) = explode('/', $range, 2); |
|
72 | 72 | $range_decimal = ip2long($range); |
73 | 73 | $ip_decimal = ip2long($ip); |
74 | 74 | $wildcard_decimal = pow(2, (32 - $netmask)) - 1; |
75 | 75 | $netmask_decimal = ~ $wildcard_decimal; |
76 | - return ( ( $ip_decimal & $netmask_decimal ) == ( $range_decimal & $netmask_decimal ) ); |
|
76 | + return (($ip_decimal & $netmask_decimal) == ($range_decimal & $netmask_decimal)); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | public function getErrorMessage() |
@@ -26,7 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | $result = []; |
28 | 28 | foreach ($this->params as $param) { |
29 | - $result[ $param->getKey() ] = $param->getValue(); |
|
29 | + $result[$param->getKey()] = $param->getValue(); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | return $result; |
@@ -2,6 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Tomaj\NetteApi\Presenters; |
4 | 4 | |
5 | +use Exception; |
|
5 | 6 | use Nette\Application\Responses\JsonResponse; |
6 | 7 | use Nette\Application\UI\Presenter; |
7 | 8 | use Nette\Http\Response; |
@@ -9,7 +10,6 @@ discard block |
||
9 | 10 | use Tomaj\NetteApi\ApiResponse; |
10 | 11 | use Tomaj\NetteApi\Misc\IpDetectorInterface; |
11 | 12 | use Tomaj\NetteApi\Params\ParamsProcessor; |
12 | -use Exception; |
|
13 | 13 | |
14 | 14 | class ApiPresenter extends Presenter |
15 | 15 | { |
@@ -107,6 +107,9 @@ |
||
107 | 107 | return $paramsProcessor->getValues(); |
108 | 108 | } |
109 | 109 | |
110 | + /** |
|
111 | + * @param double $elapsed |
|
112 | + */ |
|
110 | 113 | private function logRequest($logger, $code, $elapsed) |
111 | 114 | { |
112 | 115 | $headers = []; |
@@ -68,7 +68,7 @@ |
||
68 | 68 | $end = microtime(true); |
69 | 69 | |
70 | 70 | if ($this->context->hasService('apiLogger')) { |
71 | - $this->logRequest($this->context->getService('apiLogger'), $code, $end-$start); |
|
71 | + $this->logRequest($this->context->getService('apiLogger'), $code, $end - $start); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // output to nette |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | */ |
52 | 52 | private function getHandlersList($version) |
53 | 53 | { |
54 | - $versionHandlers = array_filter($this->apiDecider->getHandlers(), function ($handler) use ($version) { |
|
54 | + $versionHandlers = array_filter($this->apiDecider->getHandlers(), function($handler) use ($version) { |
|
55 | 55 | return $version == $handler['endpoint']->getVersion(); |
56 | 56 | }); |
57 | 57 | |
58 | - return array_map(function ($handler) { |
|
58 | + return array_map(function($handler) { |
|
59 | 59 | return [ |
60 | 60 | 'method' => $handler['endpoint']->getMethod(), |
61 | 61 | 'version' => $handler['endpoint']->getVersion(), |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | private function createParamsList(ApiHandlerInterface $handler) |
79 | 79 | { |
80 | - return array_map(function (InputParam $param) { |
|
80 | + return array_map(function(InputParam $param) { |
|
81 | 81 | $parameter = [ |
82 | 82 | 'type' => $param->getType(), |
83 | 83 | 'key' => $param->getKey(), |