Test Failed
Push — master ( b2d464...e1b9bb )
by Erandir
02:06
created
src/Body/Content.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -10,26 +10,26 @@  discard block
 block discarded – undo
10 10
 {
11 11
 	private Server $server;
12 12
 
13
-    /**
14
-     * @var string|array
15
-     */
13
+	/**
14
+	 * @var string|array
15
+	 */
16 16
 	private $requestBody;
17 17
 
18 18
 	public function __construct(Server $server)
19 19
 	{
20 20
 		$this->server = $server;
21 21
 		$this->getBodyRequest();
22
-        $this->createProperty();
22
+		$this->createProperty();
23 23
 	}
24 24
 
25 25
 	private function getBodyRequest()
26 26
 	{
27
-        $xml = new XML();
28
-        $json = new Json();
29
-        $post = new Post();
30
-        $formData = new FormData();
31
-        $urlEncode = new FormUrlEncoded();
32
-        $textPlain = new TextPlain();
27
+		$xml = new XML();
28
+		$json = new Json();
29
+		$post = new Post();
30
+		$formData = new FormData();
31
+		$urlEncode = new FormUrlEncoded();
32
+		$textPlain = new TextPlain();
33 33
 
34 34
 		$json->next($formData);
35 35
 		$formData->next($urlEncode);
@@ -42,62 +42,62 @@  discard block
 block discarded – undo
42 42
 
43 43
 	private function createProperty()
44 44
 	{
45
-        if (is_array($this->requestBody)) {
46
-            foreach ($this->requestBody as $key => $value) {
47
-                $this->$key = $value;
48
-            }
49
-        }
50
-    }
51
-
52
-    public function add(string $key, $value): void
53
-    {
54
-        $this->requestBody[$key] = $value;
55
-
56
-        $this->__set($key, $value);
57
-    }
58
-
59
-    public function remove(string $key): void
60
-    {
61
-        unset($this->requestBody[$key]);
62
-
63
-        unset($this->$key);
64
-    }
65
-
66
-    public function get(string $key)
67
-    {
68
-        return $this->requestBody[$key];
69
-    }
70
-
71
-    /**
72
-     * @return array|string
73
-     */
74
-    public function all()
75
-    {
76
-        return $this->requestBody;
77
-    }
78
-
79
-    public function __set($name, $value)
80
-    {
81
-        $this->$name = $value;
82
-    }
83
-
84
-    public function __get($name)
85
-    {
86
-        $this->$name;
87
-    }
88
-
89
-    public function except(array $keys): array
90
-    {
91
-        return ArrayUtil::except($this->requestBody, $keys);
92
-    }
93
-
94
-    public function only(array $keys): array
95
-    {
96
-        return ArrayUtil::only($this->requestBody, $keys);
97
-    }
98
-
99
-    public function has(string $key): bool
100
-    {
101
-        return !empty($this->requestBody[$key]);
102
-    }
45
+		if (is_array($this->requestBody)) {
46
+			foreach ($this->requestBody as $key => $value) {
47
+				$this->$key = $value;
48
+			}
49
+		}
50
+	}
51
+
52
+	public function add(string $key, $value): void
53
+	{
54
+		$this->requestBody[$key] = $value;
55
+
56
+		$this->__set($key, $value);
57
+	}
58
+
59
+	public function remove(string $key): void
60
+	{
61
+		unset($this->requestBody[$key]);
62
+
63
+		unset($this->$key);
64
+	}
65
+
66
+	public function get(string $key)
67
+	{
68
+		return $this->requestBody[$key];
69
+	}
70
+
71
+	/**
72
+	 * @return array|string
73
+	 */
74
+	public function all()
75
+	{
76
+		return $this->requestBody;
77
+	}
78
+
79
+	public function __set($name, $value)
80
+	{
81
+		$this->$name = $value;
82
+	}
83
+
84
+	public function __get($name)
85
+	{
86
+		$this->$name;
87
+	}
88
+
89
+	public function except(array $keys): array
90
+	{
91
+		return ArrayUtil::except($this->requestBody, $keys);
92
+	}
93
+
94
+	public function only(array $keys): array
95
+	{
96
+		return ArrayUtil::only($this->requestBody, $keys);
97
+	}
98
+
99
+	public function has(string $key): bool
100
+	{
101
+		return !empty($this->requestBody[$key]);
102
+	}
103 103
 }
104 104
\ No newline at end of file
Please login to merge, or discard this patch.
src/Body/TextPlain.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
 
7 7
 class TextPlain implements Handler, Advancer
8 8
 {
9
-    private Handler $handler;
9
+	private Handler $handler;
10 10
 
11
-    public function getBody($content): array
12
-    {
13
-        return [$content];
14
-    }
11
+	public function getBody($content): array
12
+	{
13
+		return [$content];
14
+	}
15 15
 
16
-    public function next(Handler $handler)
17
-    {
18
-        $this->handler = $handler;
19
-    }
16
+	public function next(Handler $handler)
17
+	{
18
+		$this->handler = $handler;
19
+	}
20 20
 
21
-    public function handle($server): array
22
-    {
23
-        if (ContentHelper::contentIs($server, 'text/plain')) {
24
-            return $this->getBody($server->getContent());
25
-        }
21
+	public function handle($server): array
22
+	{
23
+		if (ContentHelper::contentIs($server, 'text/plain')) {
24
+			return $this->getBody($server->getContent());
25
+		}
26 26
 
27
-        return $this->handler->handle($server);
28
-    }
27
+		return $this->handler->handle($server);
28
+	}
29 29
 }
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
src/Body/FormUrlEncoded.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -11,30 +11,30 @@
 block discarded – undo
11 11
 	private array $data;
12 12
 
13 13
 	public function __construct()
14
-    {
15
-        $this->data = [];
16
-    }
14
+	{
15
+		$this->data = [];
16
+	}
17 17
 
18
-    public function getBody($content): array
18
+	public function getBody($content): array
19 19
 	{
20
-	    if (is_array($content)) {
21
-	        return $content;
22
-        }
20
+		if (is_array($content)) {
21
+			return $content;
22
+		}
23 23
 
24
-	    $this->handleSentData($content);
24
+		$this->handleSentData($content);
25 25
 
26
-	    return $this->data;
26
+		return $this->data;
27 27
 	}
28 28
 
29
-    private function handleSentData(string $content): void
30
-    {
31
-        $body = explode('&', $content);
29
+	private function handleSentData(string $content): void
30
+	{
31
+		$body = explode('&', $content);
32 32
 
33
-        foreach ($body as $parameter) {
34
-            $parameterParsed = explode('=', $parameter);
33
+		foreach ($body as $parameter) {
34
+			$parameterParsed = explode('=', $parameter);
35 35
 
36
-            $this->data[$parameterParsed[0]] = str_replace("%0A", "\n", $parameterParsed[1]);
37
-        }
36
+			$this->data[$parameterParsed[0]] = str_replace("%0A", "\n", $parameterParsed[1]);
37
+		}
38 38
 	}
39 39
 
40 40
 	public function next(Handler $handler)
Please login to merge, or discard this patch.
src/Body/XML.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,40 +6,40 @@
 block discarded – undo
6 6
 
7 7
 class XML implements Handler, Advancer
8 8
 {
9
-    private Handler $handler;
10
-
11
-    public function getBody($content): array
12
-    {
13
-        $xml = simplexml_load_string($content);
14
-        $json = json_encode($xml);
15
-
16
-        return json_decode($json, true);
17
-    }
18
-
19
-    public function next(Handler $handler)
20
-    {
21
-        $this->handler = $handler;
22
-    }
23
-
24
-    private function isTextXml($server): bool
25
-    {
26
-        return ContentHelper::contentIs($server, 'text/xml');
27
-    }
28
-
29
-    private function isApplicationXml($server): bool
30
-    {
31
-        return ContentHelper::contentIs($server, 'application/xml');
32
-    }
33
-
34
-    public function handle($server): array
35
-    {
36
-        $isTextXML = $this->isTextXml($server);
37
-        $isApplicationXML = $this->isApplicationXml($server);
38
-
39
-        if ($isTextXML || $isApplicationXML) {
40
-            return $this->getBody($server->getContent());
41
-        }
42
-
43
-        return $this->handler->handle($server);
44
-    }
9
+	private Handler $handler;
10
+
11
+	public function getBody($content): array
12
+	{
13
+		$xml = simplexml_load_string($content);
14
+		$json = json_encode($xml);
15
+
16
+		return json_decode($json, true);
17
+	}
18
+
19
+	public function next(Handler $handler)
20
+	{
21
+		$this->handler = $handler;
22
+	}
23
+
24
+	private function isTextXml($server): bool
25
+	{
26
+		return ContentHelper::contentIs($server, 'text/xml');
27
+	}
28
+
29
+	private function isApplicationXml($server): bool
30
+	{
31
+		return ContentHelper::contentIs($server, 'application/xml');
32
+	}
33
+
34
+	public function handle($server): array
35
+	{
36
+		$isTextXML = $this->isTextXml($server);
37
+		$isApplicationXML = $this->isApplicationXml($server);
38
+
39
+		if ($isTextXML || $isApplicationXML) {
40
+			return $this->getBody($server->getContent());
41
+		}
42
+
43
+		return $this->handler->handle($server);
44
+	}
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
src/Body/FormData.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -12,31 +12,31 @@
 block discarded – undo
12 12
 	private array $currentData;
13 13
 
14 14
 	public function __construct()
15
-    {
16
-        $this->currentData = [];
17
-    }
15
+	{
16
+		$this->currentData = [];
17
+	}
18 18
 
19
-    public function getBody($content): array
19
+	public function getBody($content): array
20 20
 	{
21
-        $boundary = substr($content, 0, strpos($content, "\r\n"));
22
-        $parts = array_slice(explode($boundary, $content), 1);
21
+		$boundary = substr($content, 0, strpos($content, "\r\n"));
22
+		$parts = array_slice(explode($boundary, $content), 1);
23 23
 
24
-        foreach ($parts as $part) {
25
-            preg_match_all('/"(.+)"+\s+([^\t]+)/', $part, $matches);
24
+		foreach ($parts as $part) {
25
+			preg_match_all('/"(.+)"+\s+([^\t]+)/', $part, $matches);
26 26
 
27
-            $this->handleBodySent($matches);
28
-        }
27
+			$this->handleBodySent($matches);
28
+		}
29 29
 
30
-        return $this->currentData;
30
+		return $this->currentData;
31 31
 	}
32 32
 
33
-    private function handleBodySent(array $matches): void
34
-    {
35
-        foreach ($matches[1] as $key => $match) {
36
-            $matchKey = str_replace(["'", '"'], '', $match);
33
+	private function handleBodySent(array $matches): void
34
+	{
35
+		foreach ($matches[1] as $key => $match) {
36
+			$matchKey = str_replace(["'", '"'], '', $match);
37 37
 
38
-            $this->currentData[$matchKey] = substr($matches[2][$key], 0, -2);
39
-        }
38
+			$this->currentData[$matchKey] = substr($matches[2][$key], 0, -2);
39
+		}
40 40
 	}
41 41
 
42 42
 	public function next(Handler $handler)
Please login to merge, or discard this patch.