@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | foreach ($getFields as $key => $value) { |
| 63 | 63 | $parts[] = "$key=$value"; |
| 64 | 64 | } |
| 65 | - $url = $url . '?' . implode('&', $parts); |
|
| 65 | + $url = $url.'?'.implode('&', $parts); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $putRawPost = null; |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | foreach ($cookieFields as $key => $value) { |
| 103 | 103 | $parts[] = "$key=$value"; |
| 104 | 104 | } |
| 105 | - curl_setopt($curl, CURLOPT_HTTPHEADER, ["Cookie: " . implode('&', $parts)]); |
|
| 105 | + curl_setopt($curl, CURLOPT_HTTPHEADER, ["Cookie: ".implode('&', $parts)]); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | curl_setopt($curl, CURLOPT_TIMEOUT, 30); |
| 109 | 109 | $headers = []; |
| 110 | 110 | if ($token !== null && $token !== false) { |
| 111 | - $headers = ['Authorization: Bearer ' . $token]; |
|
| 111 | + $headers = ['Authorization: Bearer '.$token]; |
|
| 112 | 112 | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | $counter = 0; |
| 247 | 247 | foreach ($value as $innerValue) { |
| 248 | 248 | if ($innerValue != null) { |
| 249 | - $result[$key . "[".$counter++."]"] = $innerValue; |
|
| 249 | + $result[$key."[".$counter++."]"] = $innerValue; |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | } else { |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | { |
| 32 | 32 | $apis = $this->apiDecider->getApis(); |
| 33 | 33 | $this->getTemplate()->add('apis', $this->groupApis($apis)); |
| 34 | - $this->getTemplate()->setFile(__DIR__ . '/api_listing.latte'); |
|
| 34 | + $this->getTemplate()->setFile(__DIR__.'/api_listing.latte'); |
|
| 35 | 35 | $this->getTemplate()->render(); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | namespace Tomaj\NetteApi\Component; |
| 4 | 4 | |
| 5 | 5 | use Nette\Application\UI\Control; |
| 6 | -use Tomaj\NetteApi\ApiDecider; |
|
| 7 | 6 | use Tomaj\NetteApi\Api; |
| 7 | +use Tomaj\NetteApi\ApiDecider; |
|
| 8 | 8 | |
| 9 | 9 | class ApiListingControl extends Control |
| 10 | 10 | { |
@@ -75,6 +75,7 @@ |
||
| 75 | 75 | * '127.0.0.1/32' - accessible from ip range |
| 76 | 76 | * false - disabled access |
| 77 | 77 | * |
| 78 | + * @param string|null $ipRestrictions |
|
| 78 | 79 | * @return boolean |
| 79 | 80 | */ |
| 80 | 81 | private function isValidIp(?string $ipRestrictions): bool |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | list($range, $netmask) = explode('/', $range, 2); |
| 114 | 114 | $range_decimal = ip2long($range); |
| 115 | 115 | $ipDecimal = ip2long($ip); |
| 116 | - $wildcard_decimal = pow(2, (32 - (int)$netmask)) - 1; |
|
| 116 | + $wildcard_decimal = pow(2, (32 - (int) $netmask)) - 1; |
|
| 117 | 117 | $netmask_decimal = ~ $wildcard_decimal; |
| 118 | 118 | return (($ipDecimal & $netmask_decimal) == ($range_decimal & $netmask_decimal)); |
| 119 | 119 | } |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | private function getApiList(int $version): array |
| 55 | 55 | { |
| 56 | - $versionApis = array_filter($this->apiDecider->getApis(), function (Api $api) use ($version) { |
|
| 56 | + $versionApis = array_filter($this->apiDecider->getApis(), function(Api $api) use ($version) { |
|
| 57 | 57 | return $version == $api->getEndpoint()->getVersion(); |
| 58 | 58 | }); |
| 59 | 59 | |
| 60 | - return array_map(function (Api $api) { |
|
| 60 | + return array_map(function(Api $api) { |
|
| 61 | 61 | return [ |
| 62 | 62 | 'method' => $api->getEndpoint()->getMethod(), |
| 63 | 63 | 'version' => $api->getEndpoint()->getVersion(), |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | private function createParamsList(ApiHandlerInterface $handler): array |
| 81 | 81 | { |
| 82 | - return array_map(function (InputParam $param) { |
|
| 82 | + return array_map(function(InputParam $param) { |
|
| 83 | 83 | $parameter = [ |
| 84 | 84 | 'type' => $param->getType(), |
| 85 | 85 | 'key' => $param->getKey(), |
@@ -196,9 +196,9 @@ |
||
| 196 | 196 | if (!(isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) { |
| 197 | 197 | return null; |
| 198 | 198 | } |
| 199 | - $url = $refererParsedUrl['scheme'] . '://' . $refererParsedUrl['host']; |
|
| 199 | + $url = $refererParsedUrl['scheme'].'://'.$refererParsedUrl['host']; |
|
| 200 | 200 | if (isset($refererParsedUrl['port']) && $refererParsedUrl['port'] !== 80) { |
| 201 | - $url .= ':' . $refererParsedUrl['port']; |
|
| 201 | + $url .= ':'.$refererParsedUrl['port']; |
|
| 202 | 202 | } |
| 203 | 203 | return $url; |
| 204 | 204 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function render(): void |
| 36 | 36 | { |
| 37 | - $this->getTemplate()->setFile(__DIR__ . '/console.latte'); |
|
| 37 | + $this->getTemplate()->setFile(__DIR__.'/console.latte'); |
|
| 38 | 38 | $this->getTemplate()->render(); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | $port = ''; |
| 55 | 55 | if ($uri->scheme == 'http' && $uri->port != 80) { |
| 56 | - $port = ':' . $uri->port; |
|
| 56 | + $port = ':'.$uri->port; |
|
| 57 | 57 | } |
| 58 | - $url = $scheme . '://' . $uri->host . $port . '/api/' . $this->endpoint->getUrl(); |
|
| 58 | + $url = $scheme.'://'.$uri->host.$port.'/api/'.$this->endpoint->getUrl(); |
|
| 59 | 59 | |
| 60 | 60 | $form->addText('api_url', 'Api Url'); |
| 61 | 61 | $defaults['api_url'] = $url; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | const TYPE_FILE = 'FILE'; |
| 14 | 14 | const TYPE_COOKIE = 'COOKIE'; |
| 15 | 15 | const TYPE_POST_RAW = 'POST_RAW'; |
| 16 | - const TYPE_POST_JSON = 'POST_JSON'; |
|
| 16 | + const TYPE_POST_JSON = 'POST_JSON'; |
|
| 17 | 17 | |
| 18 | 18 | const OPTIONAL = false; |
| 19 | 19 | const REQUIRED = true; |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | public function updateConsoleForm(Form $form): void |
| 87 | 87 | { |
| 88 | - $count = $this->isMulti() ? 5 : 1; // TODO moznost nastavit kolko inputov sa ma vygenerovat v konzole, default moze byt 5 |
|
| 88 | + $count = $this->isMulti() ? 5 : 1; // TODO moznost nastavit kolko inputov sa ma vygenerovat v konzole, default moze byt 5 |
|
| 89 | 89 | for ($i = 0; $i < $count; $i++) { |
| 90 | 90 | $key = $this->getKey(); |
| 91 | 91 | if ($this->isMulti()) { |
| 92 | - $key = $key . '___' . $i; |
|
| 92 | + $key = $key.'___'.$i; |
|
| 93 | 93 | } |
| 94 | 94 | $this->addFormInput($form, $key); |
| 95 | 95 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | if ($this->getAvailableValues()) { |
| 101 | 101 | $select = $form->addSelect($key, $this->getParamLabel(), array_combine($this->getAvailableValues(), $this->getAvailableValues())) |
| 102 | - ->setPrompt('Select ' . $this->getLabel()); |
|
| 102 | + ->setPrompt('Select '.$this->getLabel()); |
|
| 103 | 103 | return $select; |
| 104 | 104 | } |
| 105 | 105 | return $form->addText($key, $this->getParamLabel()); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | if ($this->isRequired()) { |
| 117 | 117 | $title .= ' *'; |
| 118 | 118 | } |
| 119 | - $title .= ' (' . $this->getType() . ')'; |
|
| 119 | + $title .= ' ('.$this->getType().')'; |
|
| 120 | 120 | return $title; |
| 121 | 121 | } |
| 122 | 122 | |