Test Failed
Push — develop ( df8064...70abbc )
by nguereza
03:01
created
src/Http/Exception/HttpBadRequestException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@
 block discarded – undo
37 37
  * @class HttpBadRequestException
38 38
  * @package Platine\Framework\Http\Exception
39 39
  */
40
-class HttpBadRequestException extends HttpSpecialException
41
-{
40
+class HttpBadRequestException extends HttpSpecialException {
42 41
     /**
43 42
      *
44 43
      * @var int
Please login to merge, or discard this patch.
src/Http/Exception/HttpInternalServerErrorException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@
 block discarded – undo
37 37
  * @class HttpInternalServerErrorException
38 38
  * @package Platine\Framework\Http\Exception
39 39
  */
40
-class HttpInternalServerErrorException extends HttpSpecialException
41
-{
40
+class HttpInternalServerErrorException extends HttpSpecialException {
42 41
     /**
43 42
      *
44 43
      * @var int
Please login to merge, or discard this patch.
src/Http/Exception/HttpSpecialException.php 1 patch
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
  * @class HttpSpecialException
41 41
  * @package Platine\Framework\Http\Exception
42 42
  */
43
-abstract class HttpSpecialException extends HttpException
44
-{
43
+abstract class HttpSpecialException extends HttpException {
45 44
     /**
46 45
      * Create new instance
47 46
      * @param ServerRequestInterface $request
@@ -52,8 +51,8 @@  discard block
 block discarded – undo
52 51
         ServerRequestInterface $request,
53 52
         ?string $message = null,
54 53
         ?Throwable $previous = null
55
-    ) {
56
-        if ($message !== null) {
54
+    ) {
55
+        if ($message !== null) {
57 56
             $this->message = $message;
58 57
         }
59 58
 
Please login to merge, or discard this patch.
src/Http/Exception/HttpUnauthorizedException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@
 block discarded – undo
37 37
  * @class HttpUnauthorizedException
38 38
  * @package Platine\Framework\Http\Exception
39 39
  */
40
-class HttpUnauthorizedException extends HttpSpecialException
41
-{
40
+class HttpUnauthorizedException extends HttpSpecialException {
42 41
     /**
43 42
      *
44 43
      * @var int
Please login to merge, or discard this patch.
src/Http/Exception/HttpMethodNotAllowedException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@
 block discarded – undo
37 37
  * @class HttpMethodNotAllowedException
38 38
  * @package Platine\Framework\Http\Exception
39 39
  */
40
-class HttpMethodNotAllowedException extends HttpSpecialException
41
-{
40
+class HttpMethodNotAllowedException extends HttpSpecialException {
42 41
     /**
43 42
      *
44 43
      * @var int
Please login to merge, or discard this patch.
src/Http/Client/HttpClient.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -271,8 +271,8 @@
 block discarded – undo
271 271
      */
272 272
     public function contentType(string $contentType): self
273 273
     {
274
-       // If this is a multipart request and boundary was not defined,
275
-       // we define a boundary as this is required for multipart requests.
274
+        // If this is a multipart request and boundary was not defined,
275
+        // we define a boundary as this is required for multipart requests.
276 276
         if (stripos($contentType, 'multipart/') !== false) {
277 277
             if (stripos($contentType, 'boundary') === false) {
278 278
                 $contentType .= sprintf('; boundary="%s"', uniqid((string) time()));
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -519,7 +519,7 @@
 block discarded – undo
519 519
     protected function send($ch): HttpResponse
520 520
     {
521 521
         $responseHeaders = [];
522
-        curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$responseHeaders) {
522
+        curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$responseHeaders) {
523 523
             if (strpos($header, ':') !== false) {
524 524
                 list($name, $value) = explode(':', $header);
525 525
                 if (array_key_exists($name, $responseHeaders) === false) {
Please login to merge, or discard this patch.
Braces   +32 added lines, -34 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
56 56
  * @class HttpClient
57 57
  * @package Platine\Framework\Http\Client
58 58
  */
59
-class HttpClient
60
-{
59
+class HttpClient {
61 60
     /**
62 61
      * The base URL
63 62
      * @var string
@@ -110,8 +109,7 @@  discard block
 block discarded – undo
110 109
      * Create new instance
111 110
      * @param string $baseUrl
112 111
      */
113
-    public function __construct(string $baseUrl = '')
114
-    {
112
+    public function __construct(string $baseUrl = '') {
115 113
         $this->baseUrl = $baseUrl;
116 114
     }
117 115
 
@@ -144,7 +142,7 @@  discard block
 block discarded – undo
144 142
      */
145 143
     public function header(string $name, $value): self
146 144
     {
147
-        if (array_key_exists($name, $this->headers) === false) {
145
+        if (array_key_exists($name, $this->headers) === false) {
148 146
             $this->headers[$name] = [];
149 147
         }
150 148
         $this->headers[$name][] = $value;
@@ -159,7 +157,7 @@  discard block
 block discarded – undo
159 157
      */
160 158
     public function headers(array $headers): self
161 159
     {
162
-        foreach ($headers as $name => $value) {
160
+        foreach ($headers as $name => $value) {
163 161
             $this->header($name, $value);
164 162
         }
165 163
 
@@ -187,7 +185,7 @@  discard block
 block discarded – undo
187 185
      */
188 186
     public function parameters(array $parameters): self
189 187
     {
190
-        foreach ($parameters as $name => $value) {
188
+        foreach ($parameters as $name => $value) {
191 189
             $this->parameter($name, $value);
192 190
         }
193 191
 
@@ -214,11 +212,11 @@  discard block
 block discarded – undo
214 212
      */
215 213
     public function cookies(?array $cookies = null): self
216 214
     {
217
-        if ($cookies === null) {
215
+        if ($cookies === null) {
218 216
             $cookies = $_COOKIE;
219 217
         }
220 218
 
221
-        foreach ($cookies as $name => $value) {
219
+        foreach ($cookies as $name => $value) {
222 220
             $this->cookie($name, $value);
223 221
         }
224 222
 
@@ -273,8 +271,8 @@  discard block
 block discarded – undo
273 271
     {
274 272
        // If this is a multipart request and boundary was not defined,
275 273
        // we define a boundary as this is required for multipart requests.
276
-        if (stripos($contentType, 'multipart/') !== false) {
277
-            if (stripos($contentType, 'boundary') === false) {
274
+        if (stripos($contentType, 'multipart/') !== false) {
275
+            if (stripos($contentType, 'boundary') === false) {
278 276
                 $contentType .= sprintf('; boundary="%s"', uniqid((string) time()));
279 277
                 // remove double semi-colon, except after scheme
280 278
                 $contentType = preg_replace('/(.)(;{2,})/', '$1;', $contentType);
@@ -519,10 +517,10 @@  discard block
 block discarded – undo
519 517
     protected function send($ch): HttpResponse
520 518
     {
521 519
         $responseHeaders = [];
522
-        curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$responseHeaders) {
523
-            if (strpos($header, ':') !== false) {
520
+        curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$responseHeaders) {
521
+            if (strpos($header, ':') !== false) {
524 522
                 list($name, $value) = explode(':', $header);
525
-                if (array_key_exists($name, $responseHeaders) === false) {
523
+                if (array_key_exists($name, $responseHeaders) === false) {
526 524
                     $responseHeaders[$name] = [];
527 525
                 }
528 526
                 $responseHeaders[$name][] = trim($value);
@@ -541,7 +539,7 @@  discard block
 block discarded – undo
541 539
         // Set verification of SSL certificates
542 540
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verifySslCertificate);
543 541
 
544
-        if (!empty($this->username)) {
542
+        if (!empty($this->username)) {
545 543
             curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
546 544
             curl_setopt($ch, CURLOPT_USERPWD, sprintf('%s:%s', $this->username, $this->password));
547 545
         }
@@ -550,7 +548,7 @@  discard block
 block discarded – undo
550 548
         $requestInfo = curl_getinfo($ch);
551 549
         $error = curl_error($ch);
552 550
         $errorCode = curl_errno($ch);
553
-        if (!empty($error)) {
551
+        if (!empty($error)) {
554 552
             throw new HttpClientException($error, $errorCode);
555 553
         }
556 554
 
@@ -576,16 +574,16 @@  discard block
 block discarded – undo
576 574
      */
577 575
     protected function buildUrl(string $path): string
578 576
     {
579
-        if (empty($this->baseUrl)) {
577
+        if (empty($this->baseUrl)) {
580 578
             throw new InvalidArgumentException('Base URL can not be empty or null');
581 579
         }
582 580
 
583 581
         $url = $this->baseUrl;
584
-        if (!empty($path)) {
582
+        if (!empty($path)) {
585 583
             $url .= $path;
586 584
         }
587 585
 
588
-        if (count($this->parameters) > 0) {
586
+        if (count($this->parameters) > 0) {
589 587
             $url .= '?' . http_build_query($this->parameters);
590 588
         }
591 589
 
@@ -607,13 +605,13 @@  discard block
 block discarded – undo
607 605
     protected function processHeaders($ch): void
608 606
     {
609 607
         $headers = [];
610
-        foreach ($this->headers as $name => $values) {
611
-            foreach ($values as $value) {
608
+        foreach ($this->headers as $name => $values) {
609
+            foreach ($values as $value) {
612 610
                 $headers[] = sprintf('%s: %s', $name, $value);
613 611
             }
614 612
         }
615 613
 
616
-        if (count($headers) > 0) {
614
+        if (count($headers) > 0) {
617 615
             curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
618 616
         }
619 617
     }
@@ -626,10 +624,10 @@  discard block
 block discarded – undo
626 624
     protected function processCookies($ch): void
627 625
     {
628 626
         $cookies = [];
629
-        foreach ($this->cookies as $name => $value) {
627
+        foreach ($this->cookies as $name => $value) {
630 628
             $cookies[] = sprintf('%s=%s', $name, $value);
631 629
         }
632
-        if (count($cookies) > 0) {
630
+        if (count($cookies) > 0) {
633 631
             curl_setopt($ch, CURLOPT_COOKIE, implode(';', $cookies));
634 632
         }
635 633
     }
@@ -642,17 +640,17 @@  discard block
 block discarded – undo
642 640
      */
643 641
     protected function processBody($ch, $body = null): void
644 642
     {
645
-        if ($body === null) {
643
+        if ($body === null) {
646 644
             return;
647 645
         }
648 646
 
649
-        if (isset($this->headers['Content-Type'][0])) {
647
+        if (isset($this->headers['Content-Type'][0])) {
650 648
             $contentType = $this->headers['Content-Type'][0];
651
-            if (stripos($contentType, 'application/json') !== false) {
649
+            if (stripos($contentType, 'application/json') !== false) {
652 650
                 $body = Json::encode($body);
653
-            } elseif (stripos($contentType, 'application/x-www-form-urlencoded') !== false) {
651
+            } elseif (stripos($contentType, 'application/x-www-form-urlencoded') !== false) {
654 652
                 $body = http_build_query($body);
655
-            } elseif (stripos($contentType, 'multipart/form-data') !== false) {
653
+            } elseif (stripos($contentType, 'multipart/form-data') !== false) {
656 654
                 $boundary = $this->parseBoundaryFromContentType($contentType);
657 655
                 $body = $this->buildMultipartBody(/** @var array<mixed> $body */ $body, $boundary);
658 656
             }
@@ -669,7 +667,7 @@  discard block
 block discarded – undo
669 667
     protected function parseBoundaryFromContentType(string $contentType): string
670 668
     {
671 669
         $match = [];
672
-        if (preg_match('/boundary="([^\"]+)"/is', $contentType, $match) > 0) {
670
+        if (preg_match('/boundary="([^\"]+)"/is', $contentType, $match) > 0) {
673 671
             return $match[1];
674 672
         }
675 673
 
@@ -688,18 +686,18 @@  discard block
 block discarded – undo
688 686
     protected function buildMultipartBody(array $fields, string $boundary): string
689 687
     {
690 688
         $body = '';
691
-        foreach ($fields as $name => $value) {
692
-            if (is_array($value)) {
689
+        foreach ($fields as $name => $value) {
690
+            if (is_array($value)) {
693 691
                 $data = $value['data'];
694 692
                 $filename = $value['filename'] ?? false;
695 693
 
696 694
                 $body .= sprintf("--%s\nContent-Disposition: form-data; name=\"%s\"", $boundary, $name);
697
-                if ($filename !== false) {
695
+                if ($filename !== false) {
698 696
                     $body .= sprintf(";filename=\"%s\"", $filename);
699 697
                 }
700 698
 
701 699
                 $body .= sprintf("\n\n%s\n", $data);
702
-            } elseif (!empty($value)) {
700
+            } elseif (!empty($value)) {
703 701
                 $body .= sprintf(
704 702
                     "--%s\nContent-Disposition: form-data; name=\"%s\"\n\n%s\n",
705 703
                     $boundary,
Please login to merge, or discard this patch.
src/Http/Client/HttpStatus.php 2 patches
Braces   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@  discard block
 block discarded – undo
58 58
  * @class HttpStatus
59 59
  * @package Platine\Framework\Http\Client
60 60
  */
61
-class HttpStatus
62
-{
61
+class HttpStatus {
63 62
     // Informational 1xx:
64 63
     public const INFORMATIONAL = 100;
65 64
     public const CONTINUE = 100;
@@ -232,7 +231,7 @@  discard block
 block discarded – undo
232 231
      */
233 232
     public static function getReasonPhrase(int $statusCode): string
234 233
     {
235
-        if (array_key_exists($statusCode, self::REASON_PHRASES)) {
234
+        if (array_key_exists($statusCode, self::REASON_PHRASES)) {
236 235
             return self::REASON_PHRASES[$statusCode];
237 236
         }
238 237
         throw new InvalidArgumentException('Invalid status code');
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 {
63 63
     // Informational 1xx:
64 64
     public const INFORMATIONAL = 100;
65
-    public const CONTINUE = 100;
65
+    public const continue = 100;
66 66
     public const SWITCHING_PROTOCOLS = 101;
67 67
 
68 68
     // Successful 2xx:
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     public const SERVER_ERROR_END = 600;
119 119
 
120 120
     public const REASON_PHRASES = [
121
-        self::CONTINUE => 'Continue',
121
+        self::continue => 'Continue',
122 122
         self::SWITCHING_PROTOCOLS => 'Switching Protocols',
123 123
 
124 124
         self::OK => 'OK',
Please login to merge, or discard this patch.
src/Http/Client/HttpMethod.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@
 block discarded – undo
52 52
  * @class HttpMethod
53 53
  * @package Platine\Framework\Http\Client
54 54
  */
55
-class HttpMethod
56
-{
55
+class HttpMethod {
57 56
     public const HEAD = 'HEAD';
58 57
     public const GET = 'GET';
59 58
     public const PUT = 'PUT';
Please login to merge, or discard this patch.
src/Http/Client/HttpCookie.php 1 patch
Braces   +11 added lines, -13 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@  discard block
 block discarded – undo
52 52
  * @class HttpCookie
53 53
  * @package Platine\Framework\Http\Client
54 54
  */
55
-class HttpCookie
56
-{
55
+class HttpCookie {
57 56
     /**
58 57
      * The name of cookie
59 58
      * @var string
@@ -113,28 +112,27 @@  discard block
 block discarded – undo
113 112
      * Create new instance
114 113
      * @param string $cookieString
115 114
      */
116
-    public function __construct(string $cookieString)
117
-    {
115
+    public function __construct(string $cookieString) {
118 116
         $parts = array_map('trim', explode(';', $cookieString));
119
-        foreach ($parts as $partStr) {
117
+        foreach ($parts as $partStr) {
120 118
             $part = array_map('trim', explode('=', $partStr));
121 119
             $name = $part[0];
122 120
             $value = $part[1] ?? '';
123
-            if (stripos($name, 'Expires') !== false) {
121
+            if (stripos($name, 'Expires') !== false) {
124 122
                 $this->expires = (int) strtotime($value);
125
-            } elseif (stripos($name, 'Max-Age') !== false) {
123
+            } elseif (stripos($name, 'Max-Age') !== false) {
126 124
                 $this->maxAge = intval($value);
127
-            } elseif (stripos($name, 'Domain') !== false) {
125
+            } elseif (stripos($name, 'Domain') !== false) {
128 126
                 $this->domain = $value;
129
-            } elseif (stripos($name, 'Path') !== false) {
127
+            } elseif (stripos($name, 'Path') !== false) {
130 128
                 $this->path = $value;
131
-            } elseif (stripos($name, 'Secure') !== false) {
129
+            } elseif (stripos($name, 'Secure') !== false) {
132 130
                 $this->secure = true;
133
-            } elseif (stripos($name, 'HttpOnly') !== false) {
131
+            } elseif (stripos($name, 'HttpOnly') !== false) {
134 132
                 $this->httpOnly = true;
135
-            } elseif (stripos($name, 'SameSite') !== false) {
133
+            } elseif (stripos($name, 'SameSite') !== false) {
136 134
                 $this->sameSite = $value;
137
-            } else {
135
+            } else {
138 136
                 $this->name = $name;
139 137
                 $this->value = $value;
140 138
             }
Please login to merge, or discard this patch.