@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | * @param array $params |
| 29 | 29 | * @return Response |
| 30 | 30 | */ |
| 31 | - public function execute(Request $request, $params=[]) |
|
| 31 | + public function execute(Request $request, $params = []) |
|
| 32 | 32 | { |
| 33 | 33 | $connection = $this->getConnection(); |
| 34 | 34 | $conn = $this->_getCurlConnection($connection->getConfig('persistent')); |
| 35 | - $url = $this->_scheme.'://'.$connection->getHost().':'.$connection->getPort(); |
|
| 35 | + $url = $this->_scheme . '://' . $connection->getHost() . ':' . $connection->getPort(); |
|
| 36 | 36 | $endpoint = $request->getPath(); |
| 37 | 37 | $url .= $endpoint; |
| 38 | 38 | $url = $this->setupURI($url, $request->getQuery()); |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | curl_setopt($conn, CURLOPT_CUSTOMREQUEST, $method); |
| 59 | 59 | curl_setopt($conn, CURLOPT_HTTPHEADER, $headers); |
| 60 | 60 | |
| 61 | - if ($connection->getConnectTimeout()>0) { |
|
| 61 | + if ($connection->getConnectTimeout() > 0) { |
|
| 62 | 62 | curl_setopt($conn, CURLOPT_CONNECTTIMEOUT, $connection->getConnectTimeout()); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | if ($connection->getConfig('username') !== null && $connection->getConfig('password') !== null) { |
| 66 | 66 | curl_setopt($conn, CURLOPT_HTTPAUTH, CURLAUTH_ANY); |
| 67 | - curl_setopt($conn, CURLOPT_USERPWD, $connection->getConfig('username').":".$connection->getConfig('password')); |
|
| 67 | + curl_setopt($conn, CURLOPT_USERPWD, $connection->getConfig('username') . ":" . $connection->getConfig('password')); |
|
| 68 | 68 | } |
| 69 | 69 | if ($connection->getConfig('proxy') !== null) { |
| 70 | 70 | curl_setopt($conn, CURLOPT_PROXY, $connection->getConfig('proxy')); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | 'body' => $request->getBody() |
| 97 | 97 | ]); |
| 98 | 98 | //hard error |
| 99 | - if ($errorno>0) { |
|
| 99 | + if ($errorno > 0) { |
|
| 100 | 100 | $error = curl_error($conn); |
| 101 | 101 | self::$_curl = false; |
| 102 | 102 | throw new ConnectionException($error, $request); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param bool $persistent |
| 129 | 129 | * @return false|resource |
| 130 | 130 | */ |
| 131 | - protected function _getCurlConnection(bool $persistent=true) |
|
| 131 | + protected function _getCurlConnection(bool $persistent = true) |
|
| 132 | 132 | { |
| 133 | 133 | if (!$persistent || !self::$_curl) { |
| 134 | 134 | self::$_curl = curl_init(); |
@@ -159,13 +159,13 @@ |
||
| 159 | 159 | * @param bool $obj |
| 160 | 160 | * @return array|Response |
| 161 | 161 | */ |
| 162 | - public function search(array $params = [],$obj=false) |
|
| 162 | + public function search(array $params = [], $obj = false) |
|
| 163 | 163 | { |
| 164 | 164 | $endpoint = new Endpoints\Search($params); |
| 165 | 165 | $response = $this->request($endpoint); |
| 166 | - if($obj ===true) { |
|
| 166 | + if ($obj === true) { |
|
| 167 | 167 | return $response; |
| 168 | - }else{ |
|
| 168 | + } else { |
|
| 169 | 169 | return $response->getResponse(); |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -165,7 +165,7 @@ |
||
| 165 | 165 | $response = $this->request($endpoint); |
| 166 | 166 | if($obj ===true) { |
| 167 | 167 | return $response; |
| 168 | - }else{ |
|
| 168 | + } else{ |
|
| 169 | 169 | return $response->getResponse(); |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | } elseif (is_array($v)) { |
| 26 | 26 | $return[$k] = $this->_toArray($v); |
| 27 | 27 | } else { |
| 28 | - if ($v!==null) { |
|
| 28 | + if ($v !== null) { |
|
| 29 | 29 | $return[$k] = $v; |
| 30 | 30 | } else { |
| 31 | 31 | return null; |
@@ -16,11 +16,11 @@ |
||
| 16 | 16 | { |
| 17 | 17 | $option = ""; |
| 18 | 18 | if (isset($params['pattern'])) { |
| 19 | - $option = "LIKE '".$params['pattern']."'"; |
|
| 19 | + $option = "LIKE '" . $params['pattern'] . "'"; |
|
| 20 | 20 | } |
| 21 | 21 | if (isset($params['where'])) { |
| 22 | - $option = "WHERE variable_name='".$params['where']['variable_name']."'"; |
|
| 22 | + $option = "WHERE variable_name='" . $params['where']['variable_name'] . "'"; |
|
| 23 | 23 | } |
| 24 | - return parent::setBody(['query' => "SHOW ".($params['type'] ?? '')." VARIABLES ".$option]); |
|
| 24 | + return parent::setBody(['query' => "SHOW " . ($params['type'] ?? '') . " VARIABLES " . $option]); |
|
| 25 | 25 | } |
| 26 | 26 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public $retries; |
| 27 | 27 | |
| 28 | - public $retries_attempts =0; |
|
| 28 | + public $retries_attempts = 0; |
|
| 29 | 29 | |
| 30 | 30 | public function __construct(array $connections, SelectorInterface $strategy, int $retries) |
| 31 | 31 | { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public function getConnection(): Connection |
| 53 | 53 | { |
| 54 | 54 | $this->retries_attempts++; |
| 55 | - $connection = $this->strategy->getConnection($this->_connections); |
|
| 55 | + $connection = $this->strategy->getConnection($this->_connections); |
|
| 56 | 56 | if ($connection->isAlive()) { |
| 57 | 57 | return $connection; |
| 58 | 58 | } |
@@ -30,9 +30,9 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | protected $_content_type; |
| 32 | 32 | |
| 33 | - public function __construct($params=[]) |
|
| 33 | + public function __construct($params = []) |
|
| 34 | 34 | { |
| 35 | - if (count($params)>0) { |
|
| 35 | + if (count($params) > 0) { |
|
| 36 | 36 | $this->setBody($params['body'] ?? []); |
| 37 | 37 | $this->setQuery($params['query'] ?? []); |
| 38 | 38 | $this->setContentType($params['content_type'] ?? 'application/json'); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | return $this->_client->bulk(['body' => $toreplace]); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - public function create($fields, $settings = [],$silent=false) |
|
| 152 | + public function create($fields, $settings = [], $silent = false) |
|
| 153 | 153 | { |
| 154 | 154 | $params = [ |
| 155 | 155 | 'index' => $this->_index, |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | 'settings' => $settings |
| 159 | 159 | ] |
| 160 | 160 | ]; |
| 161 | - if($silent===true) { |
|
| 161 | + if ($silent === true) { |
|
| 162 | 162 | $params['body']['silent'] = true; |
| 163 | 163 | } |
| 164 | 164 | return $this->_client->indices()->create($params); |
@@ -226,9 +226,9 @@ discard block |
||
| 226 | 226 | $this->_client->indices()->flushramchunk($params); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - public function alter($operation,$name, $type) |
|
| 229 | + public function alter($operation, $name, $type) |
|
| 230 | 230 | { |
| 231 | - if($operation==='add') { |
|
| 231 | + if ($operation === 'add') { |
|
| 232 | 232 | $params = [ |
| 233 | 233 | 'index' => $this->_index, |
| 234 | 234 | 'body' => [ |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | ] |
| 238 | 238 | ]; |
| 239 | 239 | |
| 240 | - }elseif($operation==='drop'){ |
|
| 240 | + }elseif ($operation === 'drop') { |
|
| 241 | 241 | $params = [ |
| 242 | 242 | 'index' => $this->_index, |
| 243 | 243 | 'body' => [ |
@@ -237,7 +237,7 @@ |
||
| 237 | 237 | ] |
| 238 | 238 | ]; |
| 239 | 239 | |
| 240 | - }elseif($operation==='drop'){ |
|
| 240 | + } elseif($operation==='drop'){ |
|
| 241 | 241 | $params = [ |
| 242 | 242 | 'index' => $this->_index, |
| 243 | 243 | 'body' => [ |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | |
| 14 | 14 | if (isset($response['columns'], $response['data'])) { |
| 15 | 15 | $data=[]; |
| 16 | - array_walk($response['columns'], static function (&$value, $key) { |
|
| 16 | + array_walk($response['columns'], static function (&$value, $key) { |
|
| 17 | 17 | $value= array_keys($value)[0]; |
| 18 | 18 | }); |
| 19 | 19 | foreach ($response['data'] as $property) { |
@@ -12,12 +12,12 @@ |
||
| 12 | 12 | $response = parent::getResponse(); |
| 13 | 13 | |
| 14 | 14 | if (isset($response['columns'], $response['data'])) { |
| 15 | - $data=[]; |
|
| 16 | - array_walk($response['columns'], static function (&$value, $key) { |
|
| 17 | - $value= array_keys($value)[0]; |
|
| 15 | + $data = []; |
|
| 16 | + array_walk($response['columns'], static function(&$value, $key) { |
|
| 17 | + $value = array_keys($value)[0]; |
|
| 18 | 18 | }); |
| 19 | 19 | foreach ($response['data'] as $property) { |
| 20 | - if (count($response['columns'])>2) { |
|
| 20 | + if (count($response['columns']) > 2) { |
|
| 21 | 21 | $data[array_shift($property)] = $property; |
| 22 | 22 | } else { |
| 23 | 23 | $data[$property[$response['columns'][0]]] = $property[$response['columns'][1]]; |
@@ -18,8 +18,8 @@ |
||
| 18 | 18 | $this->_body = $params; |
| 19 | 19 | if (isset($params['variable']) && is_array($params['variable'])) { |
| 20 | 20 | return parent::setBody([ |
| 21 | - 'query' => "SET " . (isset($params['type']) ? $params['type'] . "'" : "")." ". |
|
| 22 | - $params['variable']['name']."=" . $params['variable']['value'] |
|
| 21 | + 'query' => "SET " . (isset($params['type']) ? $params['type'] . "'" : "") . " " . |
|
| 22 | + $params['variable']['name'] . "=" . $params['variable']['value'] |
|
| 23 | 23 | ]); |
| 24 | 24 | |
| 25 | 25 | } |