Passed
Pull Request — master (#1136)
by Abdul Malik
11:17
created
src/Logger/src/ListenerRegistry.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
     public function addListener(callable $listener): self
16 16
     {
17
-        if (!\in_array($listener, $this->listeners, true)) {
17
+        if (!\in_array($listener, $this->listeners, true)){
18 18
             $this->listeners[] = $listener;
19 19
         }
20 20
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     public function removeListener(callable $listener): void
25 25
     {
26 26
         $key = \array_search($listener, $this->listeners, true);
27
-        if ($key !== null) {
27
+        if ($key !== null){
28 28
             unset($this->listeners[$key]);
29 29
         }
30 30
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
 
15 15
     public function addListener(callable $listener): self
16 16
     {
17
-        if (!\in_array($listener, $this->listeners, true)) {
17
+        if (!\in_array($listener, $this->listeners, true))
18
+        {
18 19
             $this->listeners[] = $listener;
19 20
         }
20 21
 
@@ -24,7 +25,8 @@  discard block
 block discarded – undo
24 25
     public function removeListener(callable $listener): void
25 26
     {
26 27
         $key = \array_search($listener, $this->listeners, true);
27
-        if ($key !== null) {
28
+        if ($key !== null)
29
+        {
28 30
             unset($this->listeners[$key]);
29 31
         }
30 32
     }
Please login to merge, or discard this patch.
src/Logger/src/LogFactory.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 {
15 15
     public function __construct(
16 16
         private readonly ListenerRegistryInterface $listenedRegistry
17
-    ) {
17
+    ){
18 18
     }
19 19
 
20 20
     public function getLogger(string $channel): LoggerInterface
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
         $e = new LogEvent(
28 28
             new \DateTime(),
29 29
             $channel,
30
-            (string) $level,
30
+            (string)$level,
31 31
             $message,
32 32
             $context
33 33
         );
34 34
 
35
-        foreach ($this->listenedRegistry->getListeners() as $listener) {
35
+        foreach ($this->listenedRegistry->getListeners() as $listener){
36 36
             \call_user_func($listener, $e);
37 37
         }
38 38
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,8 @@
 block discarded – undo
32 32
             $context
33 33
         );
34 34
 
35
-        foreach ($this->listenedRegistry->getListeners() as $listener) {
35
+        foreach ($this->listenedRegistry->getListeners() as $listener)
36
+        {
36 37
             \call_user_func($listener, $e);
37 38
         }
38 39
     }
Please login to merge, or discard this patch.
src/Cache/src/Config/CacheConfig.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function getDefaultStorage(): string
33 33
     {
34
-        if (!\is_string($this->config['default'])) {
34
+        if (!\is_string($this->config['default'])){
35 35
             throw new InvalidArgumentException('Default cache storage config value must be a string');
36 36
         }
37 37
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function getStorageConfig(string $name): array
42 42
     {
43
-        if (!isset($this->config['storages'][$name])) {
43
+        if (!isset($this->config['storages'][$name])){
44 44
             throw new InvalidArgumentException(
45 45
                 \sprintf('Config for storage `%s` is not defined.', $name)
46 46
             );
@@ -48,19 +48,19 @@  discard block
 block discarded – undo
48 48
 
49 49
         $config = $this->config['storages'][$name];
50 50
 
51
-        if (!isset($config['type'])) {
51
+        if (!isset($config['type'])){
52 52
             throw new InvalidArgumentException(
53 53
                 \sprintf('Storage type for `%s` is not defined.', $name)
54 54
             );
55 55
         }
56 56
 
57
-        if (!\is_string($config['type'])) {
57
+        if (!\is_string($config['type'])){
58 58
             throw new InvalidArgumentException(
59 59
                 \sprintf('Storage type value for `%s` must be a string', $name)
60 60
             );
61 61
         }
62 62
 
63
-        if (isset($this->config['typeAliases'][$config['type']])) {
63
+        if (isset($this->config['typeAliases'][$config['type']])){
64 64
             $config['type'] = $this->config['typeAliases'][$config['type']];
65 65
         }
66 66
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function getDefaultStorage(): string
33 33
     {
34
-        if (!\is_string($this->config['default'])) {
34
+        if (!\is_string($this->config['default']))
35
+        {
35 36
             throw new InvalidArgumentException('Default cache storage config value must be a string');
36 37
         }
37 38
 
@@ -40,7 +41,8 @@  discard block
 block discarded – undo
40 41
 
41 42
     public function getStorageConfig(string $name): array
42 43
     {
43
-        if (!isset($this->config['storages'][$name])) {
44
+        if (!isset($this->config['storages'][$name]))
45
+        {
44 46
             throw new InvalidArgumentException(
45 47
                 \sprintf('Config for storage `%s` is not defined.', $name)
46 48
             );
@@ -48,19 +50,22 @@  discard block
 block discarded – undo
48 50
 
49 51
         $config = $this->config['storages'][$name];
50 52
 
51
-        if (!isset($config['type'])) {
53
+        if (!isset($config['type']))
54
+        {
52 55
             throw new InvalidArgumentException(
53 56
                 \sprintf('Storage type for `%s` is not defined.', $name)
54 57
             );
55 58
         }
56 59
 
57
-        if (!\is_string($config['type'])) {
60
+        if (!\is_string($config['type']))
61
+        {
58 62
             throw new InvalidArgumentException(
59 63
                 \sprintf('Storage type value for `%s` must be a string', $name)
60 64
             );
61 65
         }
62 66
 
63
-        if (isset($this->config['typeAliases'][$config['type']])) {
67
+        if (isset($this->config['typeAliases'][$config['type']]))
68
+        {
64 69
             $config['type'] = $this->config['typeAliases'][$config['type']];
65 70
         }
66 71
 
Please login to merge, or discard this patch.
src/Cache/src/Event/KeyWritten.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,6 +9,6 @@
 block discarded – undo
9 9
     public function __construct(
10 10
         public readonly string $key,
11 11
         public readonly mixed $value,
12
-    ) {
12
+    ){
13 13
     }
14 14
 }
Please login to merge, or discard this patch.
src/Cache/src/Event/KeyDeleted.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,6 +8,6 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(
10 10
         public readonly string $key,
11
-    ) {
11
+    ){
12 12
     }
13 13
 }
Please login to merge, or discard this patch.
src/Cache/src/Event/CacheHit.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,6 +9,6 @@
 block discarded – undo
9 9
     public function __construct(
10 10
         public readonly string $key,
11 11
         public readonly mixed $value
12
-    ) {
12
+    ){
13 13
     }
14 14
 }
Please login to merge, or discard this patch.
src/Cache/src/Core/CacheInjector.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,26 +19,26 @@  discard block
 block discarded – undo
19 19
 {
20 20
     public function __construct(
21 21
         private readonly CacheStorageProviderInterface $provider
22
-    ) {
22
+    ){
23 23
     }
24 24
 
25 25
     public function createInjection(ReflectionClass $class, string $context = null): CacheInterface
26 26
     {
27
-        try {
28
-            if ($context === null) {
27
+        try{
28
+            if ($context === null){
29 29
                 $connection = $this->provider->storage();
30
-            } else {
30
+            }else{
31 31
                 // Get Cache by context
32
-                try {
32
+                try{
33 33
                     $connection = $this->provider->storage($context);
34
-                } catch (InvalidArgumentException) {
34
+                }catch (InvalidArgumentException){
35 35
                     // Case when context doesn't match to configured connections
36 36
                     return $this->provider->storage();
37 37
                 }
38 38
             }
39 39
 
40 40
             $this->matchType($class, $context, $connection);
41
-        } catch (\Throwable $e) {
41
+        }catch (\Throwable $e){
42 42
             throw new ContainerException(sprintf("Can't inject the required cache. %s", $e->getMessage()), 0, $e);
43 43
         }
44 44
 
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
      */
53 53
     private function matchType(ReflectionClass $class, ?string $context, CacheInterface $connection): void
54 54
     {
55
-        if ($connection::class === CacheRepository::class) {
55
+        if ($connection::class === CacheRepository::class){
56 56
             $connection = $connection->getStorage();
57 57
         }
58 58
         $className = $class->getName();
59
-        if ($className !== CacheInterface::class && !$connection instanceof $className) {
59
+        if ($className !== CacheInterface::class && !$connection instanceof $className){
60 60
             throw new \RuntimeException(
61 61
                 \sprintf(
62 62
                     "The cache obtained by the context `%s` doesn't match the type `%s`.",
Please login to merge, or discard this patch.
Braces   +19 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,21 +24,30 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function createInjection(ReflectionClass $class, string $context = null): CacheInterface
26 26
     {
27
-        try {
28
-            if ($context === null) {
27
+        try
28
+        {
29
+            if ($context === null)
30
+            {
29 31
                 $connection = $this->provider->storage();
30
-            } else {
32
+            }
33
+            else
34
+            {
31 35
                 // Get Cache by context
32
-                try {
36
+                try
37
+                {
33 38
                     $connection = $this->provider->storage($context);
34
-                } catch (InvalidArgumentException) {
39
+                }
40
+                catch (InvalidArgumentException)
41
+                {
35 42
                     // Case when context doesn't match to configured connections
36 43
                     return $this->provider->storage();
37 44
                 }
38 45
             }
39 46
 
40 47
             $this->matchType($class, $context, $connection);
41
-        } catch (\Throwable $e) {
48
+        }
49
+        catch (\Throwable $e)
50
+        {
42 51
             throw new ContainerException(sprintf("Can't inject the required cache. %s", $e->getMessage()), 0, $e);
43 52
         }
44 53
 
@@ -52,11 +61,13 @@  discard block
 block discarded – undo
52 61
      */
53 62
     private function matchType(ReflectionClass $class, ?string $context, CacheInterface $connection): void
54 63
     {
55
-        if ($connection::class === CacheRepository::class) {
64
+        if ($connection::class === CacheRepository::class)
65
+        {
56 66
             $connection = $connection->getStorage();
57 67
         }
58 68
         $className = $class->getName();
59
-        if ($className !== CacheInterface::class && !$connection instanceof $className) {
69
+        if ($className !== CacheInterface::class && !$connection instanceof $className)
70
+        {
60 71
             throw new \RuntimeException(
61 72
                 \sprintf(
62 73
                     "The cache obtained by the context `%s` doesn't match the type `%s`.",
Please login to merge, or discard this patch.
src/Cache/src/Storage/InteractsWithTime.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
         return new \DateTimeImmutable();
22 22
     }
23 23
 
24
-    private function ttlToTimestamp(null|int|\DateInterval|\DateTimeInterface $ttl = null): int
24
+    private function ttlToTimestamp(null | int | \DateInterval | \DateTimeInterface $ttl = null): int
25 25
     {
26 26
         return match (true) {
27 27
             $ttl instanceof \DateInterval => $this->now()->add($ttl)->getTimestamp(),
Please login to merge, or discard this patch.
src/Cache/src/Storage/ArrayStorage.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 
18 18
     public function __construct(
19 19
         private readonly int $ttl = 2_592_000
20
-    ) {
20
+    ){
21 21
     }
22 22
 
23 23
     public function get(string $key, mixed $default = null): mixed
24 24
     {
25
-        if (!isset($this->storage[$key])) {
25
+        if (!isset($this->storage[$key])){
26 26
             return $default;
27 27
         }
28 28
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
         $expiresAt = $item['timestamp'] ?? 0;
32 32
 
33
-        if ($expiresAt !== 0 && \time() >= $expiresAt) {
33
+        if ($expiresAt !== 0 && \time() >= $expiresAt){
34 34
             $this->delete($key);
35 35
 
36 36
             return $default;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         return $item['value'];
40 40
     }
41 41
 
42
-    public function set(string $key, mixed $value, null|int|\DateInterval|\DateTimeInterface $ttl = null): bool
42
+    public function set(string $key, mixed $value, null | int | \DateInterval | \DateTimeInterface $ttl = null): bool
43 43
     {
44 44
         $this->storage[$key] = [
45 45
             'value' => $value,
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
     public function delete(string $key): bool
53 53
     {
54
-        if ($this->has($key)) {
54
+        if ($this->has($key)){
55 55
             unset($this->storage[$key]);
56 56
 
57 57
             return true;
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $return = [];
73 73
 
74
-        foreach ($keys as $key) {
74
+        foreach ($keys as $key){
75 75
             $return[$key] = $this->get($key, $default);
76 76
         }
77 77
 
78 78
         return $return;
79 79
     }
80 80
 
81
-    public function setMultiple(iterable $values, null|int|\DateInterval|\DateTimeInterface $ttl = null): bool
81
+    public function setMultiple(iterable $values, null | int | \DateInterval | \DateTimeInterface $ttl = null): bool
82 82
     {
83
-        foreach ($values as $key => $value) {
83
+        foreach ($values as $key => $value){
84 84
             $this->set($key, $value, $ttl);
85 85
         }
86 86
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     {
92 92
         $state = null;
93 93
 
94
-        foreach ($keys as $key) {
94
+        foreach ($keys as $key){
95 95
             $result = $this->delete($key);
96 96
 
97 97
             $state = \is_null($state) ? $result : $result && $state;
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,8 @@  discard block
 block discarded – undo
22 22
 
23 23
     public function get(string $key, mixed $default = null): mixed
24 24
     {
25
-        if (!isset($this->storage[$key])) {
25
+        if (!isset($this->storage[$key]))
26
+        {
26 27
             return $default;
27 28
         }
28 29
 
@@ -30,7 +31,8 @@  discard block
 block discarded – undo
30 31
 
31 32
         $expiresAt = $item['timestamp'] ?? 0;
32 33
 
33
-        if ($expiresAt !== 0 && \time() >= $expiresAt) {
34
+        if ($expiresAt !== 0 && \time() >= $expiresAt)
35
+        {
34 36
             $this->delete($key);
35 37
 
36 38
             return $default;
@@ -51,7 +53,8 @@  discard block
 block discarded – undo
51 53
 
52 54
     public function delete(string $key): bool
53 55
     {
54
-        if ($this->has($key)) {
56
+        if ($this->has($key))
57
+        {
55 58
             unset($this->storage[$key]);
56 59
 
57 60
             return true;
@@ -71,7 +74,8 @@  discard block
 block discarded – undo
71 74
     {
72 75
         $return = [];
73 76
 
74
-        foreach ($keys as $key) {
77
+        foreach ($keys as $key)
78
+        {
75 79
             $return[$key] = $this->get($key, $default);
76 80
         }
77 81
 
@@ -80,7 +84,8 @@  discard block
 block discarded – undo
80 84
 
81 85
     public function setMultiple(iterable $values, null|int|\DateInterval|\DateTimeInterface $ttl = null): bool
82 86
     {
83
-        foreach ($values as $key => $value) {
87
+        foreach ($values as $key => $value)
88
+        {
84 89
             $this->set($key, $value, $ttl);
85 90
         }
86 91
 
@@ -91,7 +96,8 @@  discard block
 block discarded – undo
91 96
     {
92 97
         $state = null;
93 98
 
94
-        foreach ($keys as $key) {
99
+        foreach ($keys as $key)
100
+        {
95 101
             $result = $this->delete($key);
96 102
 
97 103
             $state = \is_null($state) ? $result : $result && $state;
Please login to merge, or discard this patch.