Passed
Pull Request — master (#1062)
by Maxim
10:38
created
src/Framework/Framework/Kernel.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function appBooting(\Closure ...$callbacks): void
38 38
     {
39
-        foreach ($callbacks as $callback) {
39
+        foreach ($callbacks as $callback){
40 40
             $this->bootingCallbacks[] = $callback;
41 41
         }
42 42
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function appBooted(\Closure ...$callbacks): void
53 53
     {
54
-        foreach ($callbacks as $callback) {
54
+        foreach ($callbacks as $callback){
55 55
             $this->bootedCallbacks[] = $callback;
56 56
         }
57 57
     }
@@ -89,29 +89,29 @@  discard block
 block discarded – undo
89 89
      */
90 90
     protected function mapDirectories(array $directories): array
91 91
     {
92
-        if (!isset($directories['root'])) {
92
+        if (!isset($directories['root'])){
93 93
             throw new BootException('Missing required directory `root`');
94 94
         }
95 95
 
96
-        if (!isset($directories['app'])) {
97
-            $directories['app'] = $directories['root'] . '/app/';
96
+        if (!isset($directories['app'])){
97
+            $directories['app'] = $directories['root'].'/app/';
98 98
         }
99 99
 
100 100
         return \array_merge(
101 101
             [
102 102
                 // public root
103
-                'public'    => $directories['root'] . '/public/',
103
+                'public'    => $directories['root'].'/public/',
104 104
 
105 105
                 // vendor libraries
106
-                'vendor'    => $directories['root'] . '/vendor/',
106
+                'vendor'    => $directories['root'].'/vendor/',
107 107
 
108 108
                 // data directories
109
-                'runtime'   => $directories['root'] . '/runtime/',
110
-                'cache'     => $directories['root'] . '/runtime/cache/',
109
+                'runtime'   => $directories['root'].'/runtime/',
110
+                'cache'     => $directories['root'].'/runtime/cache/',
111 111
 
112 112
                 // application directories
113
-                'config'    => $directories['app'] . '/config/',
114
-                'resources' => $directories['app'] . '/resources/',
113
+                'config'    => $directories['app'].'/config/',
114
+                'resources' => $directories['app'].'/resources/',
115 115
             ],
116 116
             $directories
117 117
         );
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,7 +36,8 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function appBooting(\Closure ...$callbacks): void
38 38
     {
39
-        foreach ($callbacks as $callback) {
39
+        foreach ($callbacks as $callback)
40
+        {
40 41
             $this->bootingCallbacks[] = $callback;
41 42
         }
42 43
     }
@@ -51,7 +52,8 @@  discard block
 block discarded – undo
51 52
      */
52 53
     public function appBooted(\Closure ...$callbacks): void
53 54
     {
54
-        foreach ($callbacks as $callback) {
55
+        foreach ($callbacks as $callback)
56
+        {
55 57
             $this->bootedCallbacks[] = $callback;
56 58
         }
57 59
     }
@@ -89,11 +91,13 @@  discard block
 block discarded – undo
89 91
      */
90 92
     protected function mapDirectories(array $directories): array
91 93
     {
92
-        if (!isset($directories['root'])) {
94
+        if (!isset($directories['root']))
95
+        {
93 96
             throw new BootException('Missing required directory `root`');
94 97
         }
95 98
 
96
-        if (!isset($directories['app'])) {
99
+        if (!isset($directories['app']))
100
+        {
97 101
             $directories['app'] = $directories['root'] . '/app/';
98 102
         }
99 103
 
Please login to merge, or discard this patch.
src/Framework/Http/PaginationFactory.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public function __construct(
21 21
         private readonly ContainerInterface $container,
22 22
         private readonly FactoryInterface $factory
23
-    ) {
23
+    ){
24 24
     }
25 25
 
26 26
     /**
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface
30 30
     {
31
-        if (!$this->container->has(ServerRequestInterface::class)) {
31
+        if (!$this->container->has(ServerRequestInterface::class)){
32 32
             throw new ScopeException('Unable to create paginator, no request scope found');
33 33
         }
34 34
         /**
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
         //Getting page number
40 40
         $page = 0;
41
-        if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) {
41
+        if (!empty($query[$parameter]) && \is_scalar($query[$parameter])){
42 42
             $page = (int)$query[$parameter];
43 43
         }
44 44
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,8 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface
30 30
     {
31
-        if (!$this->container->has(ServerRequestInterface::class)) {
31
+        if (!$this->container->has(ServerRequestInterface::class))
32
+        {
32 33
             throw new ScopeException('Unable to create paginator, no request scope found');
33 34
         }
34 35
         /**
@@ -38,7 +39,8 @@  discard block
 block discarded – undo
38 39
 
39 40
         //Getting page number
40 41
         $page = 0;
41
-        if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) {
42
+        if (!empty($query[$parameter]) && \is_scalar($query[$parameter]))
43
+        {
42 44
             $page = (int)$query[$parameter];
43 45
         }
44 46
 
Please login to merge, or discard this patch.
src/Http/tests/PipelineTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     {
26 26
         $pipeline = new Pipeline(new Container());
27 27
 
28
-        $handler = new CallableHandler(function () {
28
+        $handler = new CallableHandler(function (){
29 29
             return 'response';
30 30
         }, new ResponseFactory(new HttpConfig(['headers' => []])));
31 31
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $pipeline = new Pipeline(new Container());
42 42
 
43
-        $handler = new CallableHandler(function () {
43
+        $handler = new CallableHandler(function (){
44 44
             return 'response';
45 45
         }, new ResponseFactory(new HttpConfig(['headers' => []])));
46 46
 
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 
62 62
     public function testMiddlewareProcessingEventShouldBeDispatched(): void
63 63
     {
64
-        $middleware = new class implements MiddlewareInterface {
64
+        $middleware = new class implements MiddlewareInterface{
65 65
             public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
66 66
             {
67 67
                 return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200);
68 68
             }
69 69
         };
70 70
         $request = new ServerRequest('GET', '');
71
-        $handler = new CallableHandler(function () {
71
+        $handler = new CallableHandler(function (){
72 72
             return 'response';
73 73
         }, new ResponseFactory(new HttpConfig(['headers' => []])));
74 74
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
     {
26 26
         $pipeline = new Pipeline(new Container());
27 27
 
28
-        $handler = new CallableHandler(function () {
28
+        $handler = new CallableHandler(function ()
29
+        {
29 30
             return 'response';
30 31
         }, new ResponseFactory(new HttpConfig(['headers' => []])));
31 32
 
@@ -40,7 +41,8 @@  discard block
 block discarded – undo
40 41
     {
41 42
         $pipeline = new Pipeline(new Container());
42 43
 
43
-        $handler = new CallableHandler(function () {
44
+        $handler = new CallableHandler(function ()
45
+        {
44 46
             return 'response';
45 47
         }, new ResponseFactory(new HttpConfig(['headers' => []])));
46 48
 
@@ -61,14 +63,16 @@  discard block
 block discarded – undo
61 63
 
62 64
     public function testMiddlewareProcessingEventShouldBeDispatched(): void
63 65
     {
64
-        $middleware = new class implements MiddlewareInterface {
66
+        $middleware = new class implements MiddlewareInterface
67
+        {
65 68
             public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
66 69
             {
67 70
                 return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200);
68 71
             }
69 72
         };
70 73
         $request = new ServerRequest('GET', '');
71
-        $handler = new CallableHandler(function () {
74
+        $handler = new CallableHandler(function ()
75
+        {
72 76
             return 'response';
73 77
         }, new ResponseFactory(new HttpConfig(['headers' => []])));
74 78
 
Please login to merge, or discard this patch.
src/Http/src/Exception/ClientException.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@
 block discarded – undo
23 23
      */
24 24
     public function __construct(?int $code = null, string $message = '', ?\Throwable $previous = null)
25 25
     {
26
-        if (empty($code) && empty($this->code)) {
26
+        if (empty($code) && empty($this->code)){
27 27
             $code = self::BAD_DATA;
28 28
         }
29 29
 
30
-        if (empty($message)) {
30
+        if (empty($message)){
31 31
             $message = \sprintf('Http Error - %s', $code);
32 32
         }
33 33
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,11 +23,13 @@
 block discarded – undo
23 23
      */
24 24
     public function __construct(?int $code = null, string $message = '', ?\Throwable $previous = null)
25 25
     {
26
-        if (empty($code) && empty($this->code)) {
26
+        if (empty($code) && empty($this->code))
27
+        {
27 28
             $code = self::BAD_DATA;
28 29
         }
29 30
 
30
-        if (empty($message)) {
31
+        if (empty($message))
32
+        {
31 33
             $message = \sprintf('Http Error - %s', $code);
32 34
         }
33 35
 
Please login to merge, or discard this patch.
src/Http/src/Traits/JsonTrait.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
      */
17 17
     private function writeJson(ResponseInterface $response, mixed $payload, int $code = 200): ResponseInterface
18 18
     {
19
-        if ($payload instanceof \JsonSerializable) {
19
+        if ($payload instanceof \JsonSerializable){
20 20
             $payload = $payload->jsonSerialize();
21 21
         }
22 22
 
23
-        if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) {
23
+        if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])){
24 24
             $code = $payload['status'];
25 25
         }
26 26
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,11 +16,13 @@
 block discarded – undo
16 16
      */
17 17
     private function writeJson(ResponseInterface $response, mixed $payload, int $code = 200): ResponseInterface
18 18
     {
19
-        if ($payload instanceof \JsonSerializable) {
19
+        if ($payload instanceof \JsonSerializable)
20
+        {
20 21
             $payload = $payload->jsonSerialize();
21 22
         }
22 23
 
23
-        if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) {
24
+        if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status']))
25
+        {
24 26
             $code = $payload['status'];
25 27
         }
26 28
 
Please login to merge, or discard this patch.
src/Http/src/Event/MiddlewareProcessing.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         public readonly ServerRequestInterface $request,
14 14
         public readonly MiddlewareInterface $middleware
15
-    ) {
15
+    ){
16 16
     }
17 17
 }
Please login to merge, or discard this patch.
src/Http/src/Event/RequestHandled.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         public readonly ServerRequestInterface $request,
14 14
         public readonly ResponseInterface $response
15
-    ) {
15
+    ){
16 16
     }
17 17
 }
Please login to merge, or discard this patch.
src/Http/src/Pipeline.php 2 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,12 +51,14 @@
 block discarded – undo
51 51
 
52 52
     public function handle(Request $request): Response
53 53
     {
54
-        if ($this->handler === null) {
54
+        if ($this->handler === null)
55
+        {
55 56
             throw new PipelineException('Unable to run pipeline, no handler given.');
56 57
         }
57 58
 
58 59
         $position = $this->position++;
59
-        if (isset($this->middleware[$position])) {
60
+        if (isset($this->middleware[$position]))
61
+        {
60 62
             $middleware = $this->middleware[$position];
61 63
             $this->dispatcher?->dispatch(new MiddlewareProcessing($request, $middleware));
62 64
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         private readonly ScopeInterface $scope,
33 33
         private readonly ?EventDispatcherInterface $dispatcher = null,
34 34
         ?TracerInterface $tracer = null
35
-    ) {
35
+    ){
36 36
         $this->tracer = $tracer ?? new NullTracer($scope);
37 37
     }
38 38
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 
58 58
     public function handle(Request $request): Response
59 59
     {
60
-        if ($this->handler === null) {
60
+        if ($this->handler === null){
61 61
             throw new PipelineException('Unable to run pipeline, no handler given.');
62 62
         }
63 63
 
64 64
         $position = $this->position++;
65
-        if (isset($this->middleware[$position])) {
65
+        if (isset($this->middleware[$position])){
66 66
             $middleware = $this->middleware[$position];
67 67
             $this->dispatcher?->dispatch(new MiddlewareProcessing($request, $middleware));
68 68
 
Please login to merge, or discard this patch.
src/Http/src/Request/InputBag.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 {
16 16
     public function __construct(
17 17
         private readonly array $data,
18
-        private readonly int|string $prefix = ''
19
-    ) {
18
+        private readonly int | string $prefix = ''
19
+    ){
20 20
     }
21 21
 
22 22
     public function __debugInfo(): array
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function all(): array
33 33
     {
34
-        try {
34
+        try{
35 35
             return $this->dotGet('');
36
-        } catch (DotNotFoundException) {
36
+        }catch (DotNotFoundException){
37 37
             return [];
38 38
         }
39 39
     }
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     public function fetch(array $keys, bool $fill = false, mixed $filler = null): array
53 53
     {
54 54
         $result = \array_intersect_key($this->all(), \array_flip($keys));
55
-        if (!$fill) {
55
+        if (!$fill){
56 56
             return $result;
57 57
         }
58 58
 
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
     /**
63 63
      * Check if field presented (can be empty) by it's name. Dot notation allowed.
64 64
      */
65
-    public function has(int|string $name): bool
65
+    public function has(int | string $name): bool
66 66
     {
67
-        try {
67
+        try{
68 68
             $this->dotGet($name);
69
-        } catch (DotNotFoundException) {
69
+        }catch (DotNotFoundException){
70 70
             return false;
71 71
         }
72 72
 
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 
76 76
     public function offsetExists(mixed $offset): bool
77 77
     {
78
-        try {
78
+        try{
79 79
             return !\is_null($this->dotGet($offset));
80
-        } catch (DotNotFoundException) {
80
+        }catch (DotNotFoundException){
81 81
             return false;
82 82
         }
83 83
     }
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
     /**
91 91
      * Get property or return default value. Dot notation allowed.
92 92
      */
93
-    public function get(int|string $name, mixed $default = null): mixed
93
+    public function get(int | string $name, mixed $default = null): mixed
94 94
     {
95
-        try {
95
+        try{
96 96
             return $this->dotGet($name);
97
-        } catch (DotNotFoundException) {
97
+        }catch (DotNotFoundException){
98 98
             return $default;
99 99
         }
100 100
     }
@@ -120,20 +120,20 @@  discard block
 block discarded – undo
120 120
      *
121 121
      * @throws DotNotFoundException
122 122
      */
123
-    private function dotGet(int|string $name): mixed
123
+    private function dotGet(int | string $name): mixed
124 124
     {
125 125
         $data = $this->data;
126 126
 
127 127
         //Generating path relative to a given name and prefix
128
-        $path = (empty($this->prefix) ? '' : $this->prefix . '.') . $name;
129
-        if (empty($path)) {
128
+        $path = (empty($this->prefix) ? '' : $this->prefix.'.').$name;
129
+        if (empty($path)){
130 130
             return $data;
131 131
         }
132 132
 
133 133
         $path = \explode('.', \rtrim($path, '.'));
134 134
 
135
-        foreach ($path as $step) {
136
-            if (!\is_array($data) || !\array_key_exists($step, $data)) {
135
+        foreach ($path as $step){
136
+            if (!\is_array($data) || !\array_key_exists($step, $data)){
137 137
                 throw new DotNotFoundException(\sprintf("Unable to find requested element '%s'.", $name));
138 138
             }
139 139
 
Please login to merge, or discard this patch.
Braces   +28 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,9 +31,12 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function all(): array
33 33
     {
34
-        try {
34
+        try
35
+        {
35 36
             return $this->dotGet('');
36
-        } catch (DotNotFoundException) {
37
+        }
38
+        catch (DotNotFoundException)
39
+        {
37 40
             return [];
38 41
         }
39 42
     }
@@ -52,7 +55,8 @@  discard block
 block discarded – undo
52 55
     public function fetch(array $keys, bool $fill = false, mixed $filler = null): array
53 56
     {
54 57
         $result = \array_intersect_key($this->all(), \array_flip($keys));
55
-        if (!$fill) {
58
+        if (!$fill)
59
+        {
56 60
             return $result;
57 61
         }
58 62
 
@@ -64,9 +68,12 @@  discard block
 block discarded – undo
64 68
      */
65 69
     public function has(int|string $name): bool
66 70
     {
67
-        try {
71
+        try
72
+        {
68 73
             $this->dotGet($name);
69
-        } catch (DotNotFoundException) {
74
+        }
75
+        catch (DotNotFoundException)
76
+        {
70 77
             return false;
71 78
         }
72 79
 
@@ -75,9 +82,12 @@  discard block
 block discarded – undo
75 82
 
76 83
     public function offsetExists(mixed $offset): bool
77 84
     {
78
-        try {
85
+        try
86
+        {
79 87
             return !\is_null($this->dotGet($offset));
80
-        } catch (DotNotFoundException) {
88
+        }
89
+        catch (DotNotFoundException)
90
+        {
81 91
             return false;
82 92
         }
83 93
     }
@@ -92,9 +102,12 @@  discard block
 block discarded – undo
92 102
      */
93 103
     public function get(int|string $name, mixed $default = null): mixed
94 104
     {
95
-        try {
105
+        try
106
+        {
96 107
             return $this->dotGet($name);
97
-        } catch (DotNotFoundException) {
108
+        }
109
+        catch (DotNotFoundException)
110
+        {
98 111
             return $default;
99 112
         }
100 113
     }
@@ -126,14 +139,17 @@  discard block
 block discarded – undo
126 139
 
127 140
         //Generating path relative to a given name and prefix
128 141
         $path = (empty($this->prefix) ? '' : $this->prefix . '.') . $name;
129
-        if (empty($path)) {
142
+        if (empty($path))
143
+        {
130 144
             return $data;
131 145
         }
132 146
 
133 147
         $path = \explode('.', \rtrim($path, '.'));
134 148
 
135
-        foreach ($path as $step) {
136
-            if (!\is_array($data) || !\array_key_exists($step, $data)) {
149
+        foreach ($path as $step)
150
+        {
151
+            if (!\is_array($data) || !\array_key_exists($step, $data))
152
+            {
137 153
                 throw new DotNotFoundException(\sprintf("Unable to find requested element '%s'.", $name));
138 154
             }
139 155
 
Please login to merge, or discard this patch.