@@ -22,29 +22,29 @@ |
||
| 22 | 22 | |
| 23 | 23 | class Node |
| 24 | 24 | { |
| 25 | - protected UriInterface $uri; |
|
| 26 | - protected bool $alive = true; |
|
| 27 | - |
|
| 28 | - public function __construct(string $host) |
|
| 29 | - { |
|
| 30 | - if (substr($host, 0, 5) !== 'http:' && substr($host, 0, 6) !== 'https:') { |
|
| 31 | - $host = sprintf("http://%s", $host); |
|
| 32 | - } |
|
| 33 | - $this->uri = Psr17FactoryDiscovery::findUriFactory()->createUri($host); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - public function markAlive(bool $alive): void |
|
| 37 | - { |
|
| 38 | - $this->alive = $alive; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - public function isAlive(): bool |
|
| 42 | - { |
|
| 43 | - return $this->alive; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - public function getUri(): UriInterface |
|
| 47 | - { |
|
| 48 | - return $this->uri; |
|
| 49 | - } |
|
| 25 | + protected UriInterface $uri; |
|
| 26 | + protected bool $alive = true; |
|
| 27 | + |
|
| 28 | + public function __construct(string $host) |
|
| 29 | + { |
|
| 30 | + if (substr($host, 0, 5) !== 'http:' && substr($host, 0, 6) !== 'https:') { |
|
| 31 | + $host = sprintf("http://%s", $host); |
|
| 32 | + } |
|
| 33 | + $this->uri = Psr17FactoryDiscovery::findUriFactory()->createUri($host); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + public function markAlive(bool $alive): void |
|
| 37 | + { |
|
| 38 | + $this->alive = $alive; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + public function isAlive(): bool |
|
| 42 | + { |
|
| 43 | + return $this->alive; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + public function getUri(): UriInterface |
|
| 47 | + { |
|
| 48 | + return $this->uri; |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | \ No newline at end of file |
@@ -20,8 +20,7 @@ |
||
| 20 | 20 | use function sprintf; |
| 21 | 21 | use function substr; |
| 22 | 22 | |
| 23 | -class Node |
|
| 24 | -{ |
|
| 23 | +class Node { |
|
| 25 | 24 | protected UriInterface $uri; |
| 26 | 25 | protected bool $alive = true; |
| 27 | 26 | |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | |
| 20 | 20 | class NoResurrect implements ResurrectInterface |
| 21 | 21 | { |
| 22 | - protected ClientInterface $client; |
|
| 22 | + protected ClientInterface $client; |
|
| 23 | 23 | |
| 24 | - public function ping(Node $node): bool |
|
| 25 | - { |
|
| 26 | - return false; |
|
| 27 | - } |
|
| 24 | + public function ping(Node $node): bool |
|
| 25 | + { |
|
| 26 | + return false; |
|
| 27 | + } |
|
| 28 | 28 | } |
| 29 | 29 | \ No newline at end of file |
@@ -17,8 +17,7 @@ |
||
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node; |
| 18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Client\ClientInterface; |
| 19 | 19 | |
| 20 | -class NoResurrect implements ResurrectInterface |
|
| 21 | -{ |
|
| 20 | +class NoResurrect implements ResurrectInterface { |
|
| 22 | 21 | protected ClientInterface $client; |
| 23 | 22 | |
| 24 | 23 | public function ping(Node $node): bool |
@@ -19,5 +19,5 @@ |
||
| 19 | 19 | |
| 20 | 20 | interface ResurrectInterface |
| 21 | 21 | { |
| 22 | - public function ping(Node $node): bool; |
|
| 22 | + public function ping(Node $node): bool; |
|
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -17,7 +17,6 @@ |
||
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node; |
| 18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Client\ClientInterface; |
| 19 | 19 | |
| 20 | -interface ResurrectInterface |
|
| 21 | -{ |
|
| 20 | +interface ResurrectInterface { |
|
| 22 | 21 | public function ping(Node $node): bool; |
| 23 | 22 | } |
| 24 | 23 | \ No newline at end of file |
@@ -23,33 +23,33 @@ |
||
| 23 | 23 | |
| 24 | 24 | class ElasticsearchResurrect implements ResurrectInterface |
| 25 | 25 | { |
| 26 | - protected ClientInterface $client; |
|
| 27 | - protected RequestFactoryInterface $requestFactory; |
|
| 26 | + protected ClientInterface $client; |
|
| 27 | + protected RequestFactoryInterface $requestFactory; |
|
| 28 | 28 | |
| 29 | - public function ping(Node $node): bool |
|
| 30 | - { |
|
| 31 | - $request = $this->getRequestFactory()->createRequest("HEAD", $node->getUri()); |
|
| 32 | - try { |
|
| 33 | - $response = $this->getClient()->sendRequest($request); |
|
| 34 | - return $response->getStatusCode() === 200; |
|
| 35 | - } catch (Exception $e) { |
|
| 36 | - return false; |
|
| 37 | - } |
|
| 38 | - } |
|
| 29 | + public function ping(Node $node): bool |
|
| 30 | + { |
|
| 31 | + $request = $this->getRequestFactory()->createRequest("HEAD", $node->getUri()); |
|
| 32 | + try { |
|
| 33 | + $response = $this->getClient()->sendRequest($request); |
|
| 34 | + return $response->getStatusCode() === 200; |
|
| 35 | + } catch (Exception $e) { |
|
| 36 | + return false; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public function getClient(): ClientInterface |
|
| 41 | - { |
|
| 42 | - if (empty($this->client)) { |
|
| 43 | - $this->client = Psr18ClientDiscovery::find(); |
|
| 44 | - } |
|
| 45 | - return $this->client; |
|
| 46 | - } |
|
| 40 | + public function getClient(): ClientInterface |
|
| 41 | + { |
|
| 42 | + if (empty($this->client)) { |
|
| 43 | + $this->client = Psr18ClientDiscovery::find(); |
|
| 44 | + } |
|
| 45 | + return $this->client; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function getRequestFactory(): RequestFactoryInterface |
|
| 49 | - { |
|
| 50 | - if (empty($this->requestFactory)) { |
|
| 51 | - $this->requestFactory = Psr17FactoryDiscovery::findRequestFactory(); |
|
| 52 | - } |
|
| 53 | - return $this->requestFactory; |
|
| 54 | - } |
|
| 48 | + public function getRequestFactory(): RequestFactoryInterface |
|
| 49 | + { |
|
| 50 | + if (empty($this->requestFactory)) { |
|
| 51 | + $this->requestFactory = Psr17FactoryDiscovery::findRequestFactory(); |
|
| 52 | + } |
|
| 53 | + return $this->requestFactory; |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | \ No newline at end of file |
@@ -21,8 +21,7 @@ |
||
| 21 | 21 | use OCA\FullTextSearch_Elasticsearch\Vendor\Http\Discovery\Psr18ClientDiscovery; |
| 22 | 22 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\RequestFactoryInterface; |
| 23 | 23 | |
| 24 | -class ElasticsearchResurrect implements ResurrectInterface |
|
| 25 | -{ |
|
| 24 | +class ElasticsearchResurrect implements ResurrectInterface { |
|
| 26 | 25 | protected ClientInterface $client; |
| 27 | 26 | protected RequestFactoryInterface $requestFactory; |
| 28 | 27 | |
@@ -20,10 +20,10 @@ |
||
| 20 | 20 | |
| 21 | 21 | class AsyncOnSuccess implements OnSuccessInterface |
| 22 | 22 | { |
| 23 | - public function success(ResponseInterface $response, int $count): Elasticsearch |
|
| 24 | - { |
|
| 25 | - $result = new Elasticsearch; |
|
| 26 | - $result->setResponse($response, true); |
|
| 27 | - return $result; |
|
| 28 | - } |
|
| 23 | + public function success(ResponseInterface $response, int $count): Elasticsearch |
|
| 24 | + { |
|
| 25 | + $result = new Elasticsearch; |
|
| 26 | + $result->setResponse($response, true); |
|
| 27 | + return $result; |
|
| 28 | + } |
|
| 29 | 29 | } |
| 30 | 30 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
| 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\Transport; |
| 16 | 16 | |
@@ -18,8 +18,7 @@ |
||
| 18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Async\OnSuccessInterface; |
| 19 | 19 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
| 20 | 20 | |
| 21 | -class AsyncOnSuccess implements OnSuccessInterface |
|
| 22 | -{ |
|
| 21 | +class AsyncOnSuccess implements OnSuccessInterface { |
|
| 23 | 22 | public function success(ResponseInterface $response, int $count): Elasticsearch |
| 24 | 23 | { |
| 25 | 24 | $result = new Elasticsearch; |
@@ -20,10 +20,10 @@ |
||
| 20 | 20 | |
| 21 | 21 | class AsyncOnSuccessNoException implements OnSuccessInterface |
| 22 | 22 | { |
| 23 | - public function success(ResponseInterface $response, int $count): Elasticsearch |
|
| 24 | - { |
|
| 25 | - $result = new Elasticsearch; |
|
| 26 | - $result->setResponse($response, false); |
|
| 27 | - return $result; |
|
| 28 | - } |
|
| 23 | + public function success(ResponseInterface $response, int $count): Elasticsearch |
|
| 24 | + { |
|
| 25 | + $result = new Elasticsearch; |
|
| 26 | + $result->setResponse($response, false); |
|
| 27 | + return $result; |
|
| 28 | + } |
|
| 29 | 29 | } |
| 30 | 30 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
| 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\Transport; |
| 16 | 16 | |
@@ -18,8 +18,7 @@ |
||
| 18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Async\OnSuccessInterface; |
| 19 | 19 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
| 20 | 20 | |
| 21 | -class AsyncOnSuccessNoException implements OnSuccessInterface |
|
| 22 | -{ |
|
| 21 | +class AsyncOnSuccessNoException implements OnSuccessInterface { |
|
| 23 | 22 | public function success(ResponseInterface $response, int $count): Elasticsearch |
| 24 | 23 | { |
| 25 | 24 | $result = new Elasticsearch; |
@@ -16,23 +16,23 @@ |
||
| 16 | 16 | |
| 17 | 17 | final class RequestOptions |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Enable or sidable the SSL verification |
|
| 21 | - */ |
|
| 22 | - public const SSL_VERIFY = 'ssl_verify'; |
|
| 19 | + /** |
|
| 20 | + * Enable or sidable the SSL verification |
|
| 21 | + */ |
|
| 22 | + public const SSL_VERIFY = 'ssl_verify'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * SSL certificate |
|
| 26 | - */ |
|
| 27 | - public const SSL_CERT = 'ssl_cert'; |
|
| 24 | + /** |
|
| 25 | + * SSL certificate |
|
| 26 | + */ |
|
| 27 | + public const SSL_CERT = 'ssl_cert'; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * SSL key |
|
| 31 | - */ |
|
| 32 | - public const SSL_KEY = 'ssl_key'; |
|
| 29 | + /** |
|
| 30 | + * SSL key |
|
| 31 | + */ |
|
| 32 | + public const SSL_KEY = 'ssl_key'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * SSL Certificate Authority (CA) bundle |
|
| 36 | - */ |
|
| 37 | - public const SSL_CA = 'ssl_ca'; |
|
| 34 | + /** |
|
| 35 | + * SSL Certificate Authority (CA) bundle |
|
| 36 | + */ |
|
| 37 | + public const SSL_CA = 'ssl_ca'; |
|
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
| 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\Transport; |
| 16 | 16 | |
@@ -14,8 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Transport; |
| 16 | 16 | |
| 17 | -final class RequestOptions |
|
| 18 | -{ |
|
| 17 | +final class RequestOptions { |
|
| 19 | 18 | /** |
| 20 | 19 | * Enable or sidable the SSL verification |
| 21 | 20 | */ |
@@ -20,25 +20,25 @@ |
||
| 20 | 20 | |
| 21 | 21 | class Guzzle implements AdapterInterface |
| 22 | 22 | { |
| 23 | - public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface |
|
| 24 | - { |
|
| 25 | - $guzzleConfig = []; |
|
| 26 | - foreach ($config as $key => $value) { |
|
| 27 | - switch ($key) { |
|
| 28 | - case RequestOptions::SSL_CERT: |
|
| 29 | - $guzzleConfig[GuzzleOptions::CERT] = $value; |
|
| 30 | - break; |
|
| 31 | - case RequestOptions::SSL_KEY: |
|
| 32 | - $guzzleConfig[GuzzleOptions::SSL_KEY] = $value; |
|
| 33 | - break; |
|
| 34 | - case RequestOptions::SSL_VERIFY: |
|
| 35 | - $guzzleConfig[GuzzleOptions::VERIFY] = $value; |
|
| 36 | - break; |
|
| 37 | - case RequestOptions::SSL_CA: |
|
| 38 | - $guzzleConfig[GuzzleOptions::VERIFY] = $value; |
|
| 39 | - } |
|
| 40 | - } |
|
| 41 | - $class = get_class($client); |
|
| 42 | - return new $class(array_merge($clientOptions, $guzzleConfig)); |
|
| 43 | - } |
|
| 23 | + public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface |
|
| 24 | + { |
|
| 25 | + $guzzleConfig = []; |
|
| 26 | + foreach ($config as $key => $value) { |
|
| 27 | + switch ($key) { |
|
| 28 | + case RequestOptions::SSL_CERT: |
|
| 29 | + $guzzleConfig[GuzzleOptions::CERT] = $value; |
|
| 30 | + break; |
|
| 31 | + case RequestOptions::SSL_KEY: |
|
| 32 | + $guzzleConfig[GuzzleOptions::SSL_KEY] = $value; |
|
| 33 | + break; |
|
| 34 | + case RequestOptions::SSL_VERIFY: |
|
| 35 | + $guzzleConfig[GuzzleOptions::VERIFY] = $value; |
|
| 36 | + break; |
|
| 37 | + case RequestOptions::SSL_CA: |
|
| 38 | + $guzzleConfig[GuzzleOptions::VERIFY] = $value; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | + $class = get_class($client); |
|
| 42 | + return new $class(array_merge($clientOptions, $guzzleConfig)); |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
| 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\Transport\Adapter; |
| 16 | 16 | |
@@ -18,8 +18,7 @@ |
||
| 18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\RequestOptions As GuzzleOptions; |
| 19 | 19 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Client\ClientInterface; |
| 20 | 20 | |
| 21 | -class Guzzle implements AdapterInterface |
|
| 22 | -{ |
|
| 21 | +class Guzzle implements AdapterInterface { |
|
| 23 | 22 | public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface |
| 24 | 23 | { |
| 25 | 24 | $guzzleConfig = []; |
@@ -18,5 +18,5 @@ |
||
| 18 | 18 | |
| 19 | 19 | interface AdapterInterface |
| 20 | 20 | { |
| 21 | - public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface; |
|
| 21 | + public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface; |
|
| 22 | 22 | } |
| 23 | 23 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
| 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\Transport\Adapter; |
| 16 | 16 | |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Client\ClientInterface; |
| 18 | 18 | |
| 19 | -interface AdapterInterface |
|
| 20 | -{ |
|
| 19 | +interface AdapterInterface { |
|
| 21 | 20 | public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface; |
| 22 | 21 | } |
| 23 | 22 | \ No newline at end of file |