@@ -16,47 +16,47 @@ |
||
16 | 16 | |
17 | 17 | class Utility |
18 | 18 | { |
19 | - const ENV_URL_PLUS_AS_SPACE = 'ELASTIC_CLIENT_URL_PLUS_AS_SPACE'; |
|
19 | + const ENV_URL_PLUS_AS_SPACE = 'ELASTIC_CLIENT_URL_PLUS_AS_SPACE'; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Get the ENV variable with a thread safe fallback criteria |
|
23 | - * @see https://github.com/elastic/elasticsearch-php/issues/1237 |
|
24 | - * |
|
25 | - * @return string | false |
|
26 | - */ |
|
27 | - public static function getEnv(string $env) |
|
28 | - { |
|
29 | - return $_SERVER[$env] ?? $_ENV[$env] ?? getenv($env); |
|
30 | - } |
|
21 | + /** |
|
22 | + * Get the ENV variable with a thread safe fallback criteria |
|
23 | + * @see https://github.com/elastic/elasticsearch-php/issues/1237 |
|
24 | + * |
|
25 | + * @return string | false |
|
26 | + */ |
|
27 | + public static function getEnv(string $env) |
|
28 | + { |
|
29 | + return $_SERVER[$env] ?? $_ENV[$env] ?? getenv($env); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Encode a string in URL using urlencode() or rawurlencode() |
|
34 | - * according to ENV_URL_PLUS_AS_SPACE. |
|
35 | - * If ENV_URL_PLUS_AS_SPACE is not defined or true use urlencode(), |
|
36 | - * otherwise use rawurlencode() |
|
37 | - * |
|
38 | - * @see https://github.com/elastic/elasticsearch-php/issues/1278 |
|
39 | - * @deprecated will be replaced by PHP function rawurlencode() |
|
40 | - */ |
|
41 | - public static function urlencode(string $url): string |
|
42 | - { |
|
43 | - $plusAsSpace = self::getEnv(self::ENV_URL_PLUS_AS_SPACE); |
|
44 | - return $plusAsSpace === false || $plusAsSpace === 'true' |
|
45 | - ? urlencode($url) |
|
46 | - : rawurlencode($url); |
|
47 | - } |
|
32 | + /** |
|
33 | + * Encode a string in URL using urlencode() or rawurlencode() |
|
34 | + * according to ENV_URL_PLUS_AS_SPACE. |
|
35 | + * If ENV_URL_PLUS_AS_SPACE is not defined or true use urlencode(), |
|
36 | + * otherwise use rawurlencode() |
|
37 | + * |
|
38 | + * @see https://github.com/elastic/elasticsearch-php/issues/1278 |
|
39 | + * @deprecated will be replaced by PHP function rawurlencode() |
|
40 | + */ |
|
41 | + public static function urlencode(string $url): string |
|
42 | + { |
|
43 | + $plusAsSpace = self::getEnv(self::ENV_URL_PLUS_AS_SPACE); |
|
44 | + return $plusAsSpace === false || $plusAsSpace === 'true' |
|
45 | + ? urlencode($url) |
|
46 | + : rawurlencode($url); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Remove all the characters not valid for a PHP variable name |
|
51 | - * The valid characters are: a-z, A-Z, 0-9 and _ (underscore) |
|
52 | - * The variable name CANNOT start with a number |
|
53 | - */ |
|
54 | - public static function formatVariableName(string $var): string |
|
55 | - { |
|
56 | - // If the first character is a digit, we append the underscore |
|
57 | - if (is_int($var[0])) { |
|
58 | - $var = '_' . $var; |
|
59 | - } |
|
60 | - return preg_replace('/[^a-zA-Z0-9_]/', '', $var); |
|
61 | - } |
|
49 | + /** |
|
50 | + * Remove all the characters not valid for a PHP variable name |
|
51 | + * The valid characters are: a-z, A-Z, 0-9 and _ (underscore) |
|
52 | + * The variable name CANNOT start with a number |
|
53 | + */ |
|
54 | + public static function formatVariableName(string $var): string |
|
55 | + { |
|
56 | + // If the first character is a digit, we append the underscore |
|
57 | + if (is_int($var[0])) { |
|
58 | + $var = '_' . $var; |
|
59 | + } |
|
60 | + return preg_replace('/[^a-zA-Z0-9_]/', '', $var); |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * Elasticsearch B.V licenses this file to you under the MIT License. |
11 | 11 | * See the LICENSE file in the project root for more information. |
12 | 12 | */ |
13 | -declare(strict_types = 1); |
|
13 | +declare(strict_types=1); |
|
14 | 14 | |
15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch; |
16 | 16 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | // If the first character is a digit, we append the underscore |
57 | 57 | if (is_int($var[0])) { |
58 | - $var = '_' . $var; |
|
58 | + $var = '_'.$var; |
|
59 | 59 | } |
60 | 60 | return preg_replace('/[^a-zA-Z0-9_]/', '', $var); |
61 | 61 | } |
@@ -14,8 +14,7 @@ |
||
14 | 14 | |
15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch; |
16 | 16 | |
17 | -class Utility |
|
18 | -{ |
|
17 | +class Utility { |
|
19 | 18 | const ENV_URL_PLUS_AS_SPACE = 'ELASTIC_CLIENT_URL_PLUS_AS_SPACE'; |
20 | 19 | |
21 | 20 | /** |
@@ -22,5 +22,5 @@ |
||
22 | 22 | */ |
23 | 23 | class ServerResponseException extends Exception implements ElasticsearchException |
24 | 24 | { |
25 | - use ResponseTrait; |
|
25 | + use ResponseTrait; |
|
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -20,7 +20,6 @@ |
||
20 | 20 | /** |
21 | 21 | * HTTP server error with 5xx status code |
22 | 22 | */ |
23 | -class ServerResponseException extends Exception implements ElasticsearchException |
|
24 | -{ |
|
23 | +class ServerResponseException extends Exception implements ElasticsearchException { |
|
25 | 24 | use ResponseTrait; |
26 | 25 | } |
27 | 26 | \ No newline at end of file |
@@ -16,7 +16,6 @@ |
||
16 | 16 | |
17 | 17 | use Throwable; |
18 | 18 | |
19 | -interface ElasticsearchException extends Throwable |
|
20 | -{ |
|
19 | +interface ElasticsearchException extends Throwable { |
|
21 | 20 | |
22 | 21 | } |
23 | 22 | \ No newline at end of file |
@@ -16,7 +16,6 @@ |
||
16 | 16 | |
17 | 17 | use Exception; |
18 | 18 | |
19 | -class HttpClientException extends Exception implements ElasticsearchException |
|
20 | -{ |
|
19 | +class HttpClientException extends Exception implements ElasticsearchException { |
|
21 | 20 | |
22 | 21 | } |
23 | 22 | \ No newline at end of file |
@@ -22,5 +22,5 @@ |
||
22 | 22 | */ |
23 | 23 | class ClientResponseException extends Exception implements ElasticsearchException |
24 | 24 | { |
25 | - use ResponseTrait; |
|
25 | + use ResponseTrait; |
|
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -20,7 +20,6 @@ |
||
20 | 20 | /** |
21 | 21 | * HTTP client error with 4xx status code |
22 | 22 | */ |
23 | -class ClientResponseException extends Exception implements ElasticsearchException |
|
24 | -{ |
|
23 | +class ClientResponseException extends Exception implements ElasticsearchException { |
|
25 | 24 | use ResponseTrait; |
26 | 25 | } |
27 | 26 | \ No newline at end of file |
@@ -16,7 +16,6 @@ |
||
16 | 16 | |
17 | 17 | use Exception; |
18 | 18 | |
19 | -class MissingParameterException extends Exception implements ElasticsearchException |
|
20 | -{ |
|
19 | +class MissingParameterException extends Exception implements ElasticsearchException { |
|
21 | 20 | |
22 | 21 | } |
23 | 22 | \ No newline at end of file |
@@ -16,7 +16,6 @@ |
||
16 | 16 | |
17 | 17 | use RuntimeException; |
18 | 18 | |
19 | -class ProductCheckException extends RuntimeException implements ElasticsearchException |
|
20 | -{ |
|
19 | +class ProductCheckException extends RuntimeException implements ElasticsearchException { |
|
21 | 20 | |
22 | 21 | } |
23 | 22 | \ No newline at end of file |
@@ -16,7 +16,6 @@ |
||
16 | 16 | |
17 | 17 | use Exception; |
18 | 18 | |
19 | -class AuthenticationException extends Exception implements ElasticsearchException |
|
20 | -{ |
|
19 | +class AuthenticationException extends Exception implements ElasticsearchException { |
|
21 | 20 | |
22 | 21 | } |
23 | 22 | \ No newline at end of file |
@@ -16,7 +16,6 @@ |
||
16 | 16 | |
17 | 17 | use Exception; |
18 | 18 | |
19 | -class ContentTypeException extends Exception implements ElasticsearchException |
|
20 | -{ |
|
19 | +class ContentTypeException extends Exception implements ElasticsearchException { |
|
21 | 20 | |
22 | 21 | } |
23 | 22 | \ No newline at end of file |