Completed
Push — 1.x ( 77ac5c...7d6a4d )
by Adrian
02:26
created
src/Manticoresearch/Request.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@
 block discarded – undo
31 31
      */
32 32
     protected $_content_type;
33 33
 
34
-    public function __construct($params=[])
34
+    public function __construct($params = [])
35 35
     {
36
-        if(count($params)>0) {
36
+        if (count($params) > 0) {
37 37
             $this->setBody($params['body'] ?? []);
38 38
             $this->setQuery($params['query'] ?? []);
39 39
             $this->setContentType($params['content_type'] ?? 'application/json');
Please login to merge, or discard this patch.
src/Manticoresearch/Client.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -325,7 +325,7 @@
 block discarded – undo
325 325
             ]);
326 326
             throw $e;
327 327
         } catch (ConnectionException $e) {
328
-            $this->_logger->warning('Manticore Search Request failed '.$this->_connectionPool->retries_attempts.':', [
328
+            $this->_logger->warning('Manticore Search Request failed ' . $this->_connectionPool->retries_attempts . ':', [
329 329
                 'exception' => $e->getMessage(),
330 330
                 'request' => $e->getRequest()->toArray()
331 331
             ]);
Please login to merge, or discard this patch.
src/Manticoresearch/Transport.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
                     $query[$k] = $v ? 'true' : 'false';
90 90
                 }
91 91
             }
92
-            $uri .=  '?' . http_build_query($query);
92
+            $uri .= '?' . http_build_query($query);
93 93
         }
94 94
         return $uri;
95 95
     }
Please login to merge, or discard this patch.
src/Manticoresearch/Transport/TransportInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      * @param array $params
20 20
      * @return mixed
21 21
      */
22
-    public function execute(Request $request, $params=[]);
22
+    public function execute(Request $request, $params = []);
23 23
 
24 24
     /**
25 25
      * @return mixed
Please login to merge, or discard this patch.
src/Manticoresearch/Transport/Http.php 2 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                     $content = $data;
55 55
                 }
56 56
                 curl_setopt($conn, CURLOPT_POSTFIELDS, $content);
57
-            }else{
57
+            } else{
58 58
                 curl_setopt($conn, CURLOPT_POSTFIELDS, '');
59 59
             }
60 60
             curl_setopt($conn, CURLOPT_CUSTOMREQUEST, $method);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             if(isset($params['responseClass'])) {
88 88
                 $responseClass = $params['responseClass'];
89 89
                 $response = new $responseClass($responseString,$status);
90
-            }else{
90
+            } else{
91 91
                 $response = new Response($responseString,$status);
92 92
             }
93 93
 
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -28,16 +28,16 @@  discard block
 block discarded – undo
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
             //@todo add persistent
35 35
             //@todo add custom headers
36 36
             $conn = $this->_getCurlConnection($connection->getConfig('persistent'));
37
-            $url = $this->_scheme.'://'.$connection->getHost().':'.$connection->getPort();
37
+            $url = $this->_scheme . '://' . $connection->getHost() . ':' . $connection->getPort();
38 38
             $endpoint = $request->getPath();
39 39
             $url .= $endpoint;
40
-            $url = $this->setupURI($url,$request->getQuery());
40
+            $url = $this->setupURI($url, $request->getQuery());
41 41
 
42 42
             curl_setopt($conn, CURLOPT_URL, $url);
43 43
             curl_setopt($conn, CURLOPT_TIMEOUT, $connection->getTimeout());
@@ -47,32 +47,32 @@  discard block
 block discarded – undo
47 47
             $method = $request->getMethod();
48 48
             $headers = $connection->getHeaders();
49 49
             $headers[] = sprintf('Content-Type: %s', $request->getContentType());
50
-            if(!empty($data)) {
50
+            if (!empty($data)) {
51 51
                 if (is_array($data)) {
52 52
                     $content = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
53 53
                 } else {
54 54
                     $content = $data;
55 55
                 }
56 56
                 curl_setopt($conn, CURLOPT_POSTFIELDS, $content);
57
-            }else{
57
+            } else {
58 58
                 curl_setopt($conn, CURLOPT_POSTFIELDS, '');
59 59
             }
60 60
             curl_setopt($conn, CURLOPT_CUSTOMREQUEST, $method);
61 61
             curl_setopt($conn, CURLOPT_HTTPHEADER, $headers);
62 62
 
63
-            if($connection->getConnectTimeout()>0) {
63
+            if ($connection->getConnectTimeout() > 0) {
64 64
                 curl_setopt($conn, CURLOPT_CONNECTTIMEOUT, $connection->getConnectTimeout());
65 65
             }
66 66
 
67
-            if($connection->getConfig('username') !== null && $connection->getConfig('password') !== null) {
67
+            if ($connection->getConfig('username') !== null && $connection->getConfig('password') !== null) {
68 68
                 curl_setopt($conn, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
69
-                curl_setopt($conn, CURLOPT_USERPWD, $connection->getConfig('username').":".$connection->getConfig('password'));
69
+                curl_setopt($conn, CURLOPT_USERPWD, $connection->getConfig('username') . ":" . $connection->getConfig('password'));
70 70
             }
71
-            if($connection->getConfig('proxy') !== null) {
71
+            if ($connection->getConfig('proxy') !== null) {
72 72
                 curl_setopt($conn, CURLOPT_PROXY, $connection->getConfig('proxy'));
73 73
             }
74
-            if(!empty($connection->getConfig('curl'))) {
75
-                foreach($connection->getConfig('curl') as $k=>$v) {
74
+            if (!empty($connection->getConfig('curl'))) {
75
+                foreach ($connection->getConfig('curl') as $k=>$v) {
76 76
                     curl_setopt($conn, $k, $v);
77 77
                 }
78 78
 
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
             $responseString = \ob_get_clean();
84 84
             $end = microtime(true);
85 85
             $errorno = curl_errno($conn);
86
-            $status = curl_getinfo($conn,CURLINFO_HTTP_CODE);
87
-            if(isset($params['responseClass'])) {
86
+            $status = curl_getinfo($conn, CURLINFO_HTTP_CODE);
87
+            if (isset($params['responseClass'])) {
88 88
                 $responseClass = $params['responseClass'];
89
-                $response = new $responseClass($responseString,$status);
90
-            }else{
91
-                $response = new Response($responseString,$status);
89
+                $response = new $responseClass($responseString, $status);
90
+            } else {
91
+                $response = new Response($responseString, $status);
92 92
             }
93 93
 
94 94
             $time = $end-$start;
@@ -99,27 +99,27 @@  discard block
 block discarded – undo
99 99
                 'body' => $request->getBody()
100 100
             ]);
101 101
             //hard error
102
-            if($errorno>0) {
102
+            if ($errorno > 0) {
103 103
                 $error = curl_error($conn);
104 104
                 self::$_curl = false;
105
-                throw new ConnectionException($error,$request);
105
+                throw new ConnectionException($error, $request);
106 106
             }
107 107
 
108 108
 
109
-            $this->_logger->debug('Request body:',[
109
+            $this->_logger->debug('Request body:', [
110 110
                 'connection' => $connection->getConfig(),
111 111
                 'payload'=> $request->getBody()
112 112
             ]);
113
-            $this->_logger->info('Request:',[
113
+            $this->_logger->info('Request:', [
114 114
                     'url' => $url,
115 115
                     'status' => $status,
116 116
                     'time' => $time
117 117
                 ]
118 118
             );
119
-            $this->_logger->debug('Response body:',[json_decode($responseString,true)]);
119
+            $this->_logger->debug('Response body:', [json_decode($responseString, true)]);
120 120
             //soft error
121
-            if($response->hasError()) {
122
-                $this->_logger->error('Response error:',[$response->getError()]);
121
+            if ($response->hasError()) {
122
+                $this->_logger->error('Response error:', [$response->getError()]);
123 123
                 throw new ResponseException($request, $response);
124 124
             }
125 125
             return $response;
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
      * @param bool $persistent
130 130
      * @return false|resource
131 131
      */
132
-    protected function _getCurlConnection(bool $persistent=true)
132
+    protected function _getCurlConnection(bool $persistent = true)
133 133
         {
134
-            if(!$persistent || !self::$_curl) {
134
+            if (!$persistent || !self::$_curl) {
135 135
                 self::$_curl = curl_init();
136 136
             }
137 137
             return self::$_curl;
Please login to merge, or discard this patch.
src/Manticoresearch/Transport/PhpHttp.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
             'payload'=> $request->getBody()
85 85
         ]);
86 86
         $this->_logger->info('Request:',[
87
-                 'url' => $url,
87
+                    'url' => $url,
88 88
                 'status' => $status,
89 89
                 'time' => $time
90 90
             ]
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
      * @param LoggerInterface|null $logger
32 32
      */
33 33
 
34
-    public function __construct(Connection $connection = null,LoggerInterface $logger = null)
34
+    public function __construct(Connection $connection = null, LoggerInterface $logger = null)
35 35
     {
36 36
         $this->client = HttpClientDiscovery::find();
37 37
         $this->messageFactory = MessageFactoryDiscovery::find();
38
-        parent::__construct($connection,$logger);
38
+        parent::__construct($connection, $logger);
39 39
     }
40 40
 
41 41
     /**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @return Response
45 45
      * @throws \Http\Client\Exception
46 46
      */
47
-    public function execute(Request $request, $params=[])
47
+    public function execute(Request $request, $params = [])
48 48
     {
49 49
         $connection = $this->getConnection();
50 50
 
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
         $message = $this->messageFactory->createRequest($method, $url, $headers, $content);
72 72
         try {
73 73
             $responsePSR = $this->client->sendRequest($message);
74
-        }catch (\Exception $e) {
75
-            throw new ConnectionException($e->getMessage(),$request);
74
+        } catch (\Exception $e) {
75
+            throw new ConnectionException($e->getMessage(), $request);
76 76
         }
77 77
         $end = microtime(true);
78 78
         $status = $responsePSR->getStatusCode();
79 79
         $response = new Response($responsePSR->getBody(), $status);
80 80
         $time = $end-$start;
81 81
         $response->setTime($time);
82
-        $this->_logger->debug('Request body:',[
82
+        $this->_logger->debug('Request body:', [
83 83
             'connection' => $connection->getConfig(),
84 84
             'payload'=> $request->getBody()
85 85
         ]);
86
-        $this->_logger->info('Request:',[
86
+        $this->_logger->info('Request:', [
87 87
                  'url' => $url,
88 88
                 'status' => $status,
89 89
                 'time' => $time
90 90
             ]
91 91
         );
92
-        $this->_logger->debug('Response body:',$response->getResponse());
92
+        $this->_logger->debug('Response body:', $response->getResponse());
93 93
 
94 94
         return $response;
95 95
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
         $message = $this->messageFactory->createRequest($method, $url, $headers, $content);
72 72
         try {
73 73
             $responsePSR = $this->client->sendRequest($message);
74
-        }catch (\Exception $e) {
74
+        } catch (\Exception $e) {
75 75
             throw new ConnectionException($e->getMessage(),$request);
76 76
         }
77 77
         $end = microtime(true);
Please login to merge, or discard this patch.
src/Manticoresearch/Endpoints/Keywords.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     public function setBody($params = null)
16 16
     {
17 17
         if (isset($this->_index)) {
18
-            $binds =[];
18
+            $binds = [];
19 19
             $binds[] = "'" . Utils::escape($params['query']) . "'";
20 20
             $binds[] = "'" . $this->_index . "'";
21 21
             if (count($params['options']) > 0) {
Please login to merge, or discard this patch.
src/Manticoresearch/Endpoints/Sql.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@
 block discarded – undo
34 34
      */
35 35
     public function getBody()
36 36
     {
37
-        if($this->_mode === 'raw') {
37
+        if ($this->_mode === 'raw') {
38 38
             $return = ['mode=raw'];
39
-            foreach($this->_body as $k=>$v) {
40
-                $return[]= $k.'='.$v;
39
+            foreach ($this->_body as $k=>$v) {
40
+                $return[] = $k . '=' . $v;
41 41
             }
42
-            return implode('&',$return);
43
-        }else{
42
+            return implode('&', $return);
43
+        } else {
44 44
             return http_build_query($this->_body);
45 45
         }
46 46
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
                 $return[]= $k.'='.$v;
41 41
             }
42 42
             return implode('&',$return);
43
-        }else{
43
+        } else{
44 44
             return http_build_query($this->_body);
45 45
         }
46 46
 
Please login to merge, or discard this patch.
src/Manticoresearch/Endpoints/Cluster/Delete.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     {
24 24
         if (isset($this->_cluster)) {
25 25
 
26
-            return parent::setBody(['query' => "DELETE CLUSTER ".$this->_cluster]);
26
+            return parent::setBody(['query' => "DELETE CLUSTER " . $this->_cluster]);
27 27
         }
28 28
         throw new RuntimeException('Cluster name is missing.');
29 29
     }
Please login to merge, or discard this patch.