Passed
Push — main ( eba6ae...851c69 )
by Pavel
01:43
created
src/Serializer.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
         $this->metadata ??= new Repository();
26 26
     }
27 27
 
28
-    public function serialize(object|array $resource): array
28
+    public function serialize(object | array $resource): array
29 29
     {
30 30
         return is_array($resource)
31 31
             ? array_map(fn($resource) => $this->serializeResource($resource), $resource)
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         return $data;
66 66
     }
67 67
 
68
-    protected function serializeAttributes(object $resource, array|null $fields): array|null
68
+    protected function serializeAttributes(object $resource, array | null $fields): array | null
69 69
     {
70 70
         if (($this->options[static::OPTIONS_NO_ATTRIBUTES] ?? false) === true) return null;
71 71
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
         $attributes = array_filter(
75 75
             $this->metadata->getResourceAttributes($resource),
76
-            fn ($key) => is_null($fields) || in_array($key, $fields)
76
+            fn($key) => is_null($fields) || in_array($key, $fields)
77 77
         );
78 78
 
79 79
         foreach ($attributes as $key => $attribute) {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         return $result;
84 84
     }
85 85
 
86
-    protected function serializeRelationships(object $resource): array|null
86
+    protected function serializeRelationships(object $resource): array | null
87 87
     {
88 88
         if ($this->includeset === null || count($this->includeset) === 0) return null;
89 89
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,7 +67,9 @@  discard block
 block discarded – undo
67 67
 
68 68
     protected function serializeAttributes(object $resource, array|null $fields): array|null
69 69
     {
70
-        if (($this->options[static::OPTIONS_NO_ATTRIBUTES] ?? false) === true) return null;
70
+        if (($this->options[static::OPTIONS_NO_ATTRIBUTES] ?? false) === true) {
71
+            return null;
72
+        }
71 73
 
72 74
         $result = [];
73 75
 
@@ -85,14 +87,18 @@  discard block
 block discarded – undo
85 87
 
86 88
     protected function serializeRelationships(object $resource): array|null
87 89
     {
88
-        if ($this->includeset === null || count($this->includeset) === 0) return null;
90
+        if ($this->includeset === null || count($this->includeset) === 0) {
91
+            return null;
92
+        }
89 93
 
90 94
         $relationships = [];
91 95
         $relationshipsMap = $this->metadata->getResourceRelationships($resource);
92 96
 
93 97
         foreach ($this->includeset as $relation => $childIncludeset) {
94 98
             // TODO: Maybe we should throw an exception here
95
-            if (!isset($relationshipsMap[$relation])) continue;
99
+            if (!isset($relationshipsMap[$relation])) {
100
+                continue;
101
+            }
96 102
 
97 103
             $value = $relationshipsMap[$relation]->getValue($resource);
98 104
 
Please login to merge, or discard this patch.
src/Includeset.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@
 block discarded – undo
19 19
             $parserInclude = explode(static::RELATION_SEPARATOR, $item, 2);
20 20
             $relation = array_shift($parserInclude);
21 21
 
22
-            if (empty($relation)) continue;
22
+            if (empty($relation)) {
23
+                continue;
24
+            }
23 25
 
24 26
             $rawChildren = array_shift($parserInclude) ?? '';
25 27
 
Please login to merge, or discard this patch.
src/Cache/ArrayCache.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
         return array_reduce(
36 36
             array_keys($values),
37
-            fn ($result, $key) => $result && $this->set($key, $values[$key], $ttl),
37
+            fn($result, $key) => $result && $this->set($key, $values[$key], $ttl),
38 38
             true
39 39
         );
40 40
     }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             throw new InvalidKeyException('Keys must be an array', 3);
58 58
         }
59 59
 
60
-        return array_map(fn ($key) => $this->get($key, $default), $keys);
60
+        return array_map(fn($key) => $this->get($key, $default), $keys);
61 61
     }
62 62
 
63 63
     public function has($key)
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
         return array_reduce(
88 88
             $keys,
89
-            fn ($result, $key) => $result && $this->delete($key),
89
+            fn($result, $key) => $result && $this->delete($key),
90 90
             true
91 91
         );
92 92
     }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     {
110 110
         try {
111 111
             if (!is_null($ttl) && is_numeric($ttl)) {
112
-                $ttl = new DateInterval(sprintf('%sS', (int)$ttl));
112
+                $ttl = new DateInterval(sprintf('%sS', (int) $ttl));
113 113
             }
114 114
         } catch (\Exception $e) {
115 115
             throw new InvalidTTLException('Failed to parse provided ttl', 1, $e);
Please login to merge, or discard this patch.
src/LinkGenerator/LinkGeneratorInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      *
19 19
      * @return array|null
20 20
      */
21
-    public function resourceLinks(object $resource): array|null;
21
+    public function resourceLinks(object $resource): array | null;
22 22
 
23 23
     /**
24 24
      * Provides links data for resource relation.
@@ -36,5 +36,5 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @return array|null
38 38
      */
39
-    public function relationshipLinks(object $resource, string $relationship): array|null;
39
+    public function relationshipLinks(object $resource, string $relationship): array | null;
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
src/LinkGenerator/SimpleLinksGenerator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
         $this->metadata ??= new Repository();
13 13
     }
14 14
 
15
-    public function resourceLinks(object $resource): array|null
15
+    public function resourceLinks(object $resource): array | null
16 16
     {
17 17
         $meta = $this->metadata->getResourceMeta($resource);
18 18
         $type = $meta->getType();
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         ];
24 24
     }
25 25
 
26
-    public function relationshipLinks(object $resource, string $relationship): array|null
26
+    public function relationshipLinks(object $resource, string $relationship): array | null
27 27
     {
28 28
         $links = [];
29 29
 
Please login to merge, or discard this patch.
src/Metadata/Factory.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
         foreach ($this->possibleFieldsReflections($resource) as $ref) {
50 50
             $attributes = array_merge($attributes, array_map(
51 51
                 // Create meta field
52
-                fn (AbstractField $field) => new Field($field, $ref),
52
+                fn(AbstractField $field) => new Field($field, $ref),
53 53
 
54 54
                 // Find and convert reflection attribute to attribute instance.
55 55
                 array_map(
56
-                    fn ($attr) => $attr->newInstance(),
56
+                    fn($attr) => $attr->newInstance(),
57 57
                     $ref->getAttributes(Attribute::class, ReflectionAttribute::IS_INSTANCEOF)
58 58
                 )
59 59
             ));
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
         foreach ($this->possibleFieldsReflections($resource) as $ref) {
74 74
             $relationships = array_merge($relationships, array_map(
75 75
                 // Create meta field
76
-                fn (AbstractField $field) => new Field($field, $ref),
76
+                fn(AbstractField $field) => new Field($field, $ref),
77 77
 
78 78
                 // Find and convert reflection attribute to attribute instance.
79 79
                 array_map(
80
-                    fn ($attr) => $attr->newInstance(),
80
+                    fn($attr) => $attr->newInstance(),
81 81
                     $ref->getAttributes(Relationship::class, ReflectionAttribute::IS_INSTANCEOF)
82 82
                 )
83 83
             ));
Please login to merge, or discard this patch.
benchmark.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/vendor/autoload.php';
3
+include_once __DIR__.'/vendor/autoload.php';
4 4
 
5 5
 use JSONAPI\Resource\Includeset;
6 6
 use JSONAPI\Resource\Serializer;
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 
16 16
 function convert($size)
17 17
 {
18
-    $unit=array('b','kb','mb','gb','tb','pb');
19
-    return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
18
+    $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
19
+    return @round($size/pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[$i];
20 20
 }
21 21
 
22 22
 $articles = [
Please login to merge, or discard this patch.