Passed
Pull Request — master (#600)
by Aleksei
06:54 queued 01:04
created
src/Cache/tests/ArrayCache.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
     public function get($key, $default = null)
30 30
     {
31 31
         $this->validateKey($key);
32
-        if (\array_key_exists($key, $this->cache) && !$this->isExpired($key)) {
32
+        if (\array_key_exists($key, $this->cache) && !$this->isExpired($key)){
33 33
             /** @psalm-var mixed $value */
34 34
             $value = $this->cache[$key][0];
35
-            if (\is_object($value)) {
35
+            if (\is_object($value)){
36 36
                 $value = clone $value;
37 37
             }
38 38
 
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
     {
47 47
         $this->validateKey($key);
48 48
         $expiration = $this->ttlToExpiration($ttl);
49
-        if ($expiration < 0) {
49
+        if ($expiration < 0){
50 50
             return $this->delete($key);
51 51
         }
52
-        if (\is_object($value)) {
52
+        if (\is_object($value)){
53 53
             $value = clone $value;
54 54
         }
55 55
         $this->cache[$key] = [$value, $expiration];
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         $this->validateKeys($keys);
82 82
         /** @psalm-var string[] $keys */
83 83
         $result = [];
84
-        foreach ($keys as $key) {
84
+        foreach ($keys as $key){
85 85
             /** @psalm-var mixed */
86 86
             $result[$key] = $this->get($key, $default);
87 87
         }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         /**
100 100
          * @psalm-var mixed $value
101 101
          */
102
-        foreach ($values as $key => $value) {
102
+        foreach ($values as $key => $value){
103 103
             $this->set((string)$key, $value, $ttl);
104 104
         }
105 105
         return $this->returnOnSet;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         $keys = $this->iterableToArray($keys);
111 111
         $this->validateKeys($keys);
112 112
         /** @var string[] $keys */
113
-        foreach ($keys as $key) {
113
+        foreach ($keys as $key){
114 114
             $this->delete($key);
115 115
         }
116 116
         return $this->returnOnDelete;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     public function getValues(): array
132 132
     {
133 133
         $result = [];
134
-        foreach ($this->cache as $key => $value) {
134
+        foreach ($this->cache as $key => $value){
135 135
             /** @psalm-var mixed */
136 136
             $result[$key] = $value[0];
137 137
         }
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
     {
158 158
         $ttl = $this->normalizeTtl($ttl);
159 159
 
160
-        if ($ttl === null) {
160
+        if ($ttl === null){
161 161
             $expiration = self::EXPIRATION_INFINITY;
162
-        } elseif ($ttl <= 0) {
162
+        } elseif ($ttl <= 0){
163 163
             $expiration = self::EXPIRATION_EXPIRED;
164
-        } else {
164
+        }else{
165 165
             $expiration = $ttl + time();
166 166
         }
167 167
 
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
      */
178 178
     private function normalizeTtl($ttl): ?int
179 179
     {
180
-        if ($ttl instanceof DateInterval) {
180
+        if ($ttl instanceof DateInterval){
181 181
             return (new DateTime('@0'))->add($ttl)->getTimestamp();
182 182
         }
183 183
 
184
-        if (\is_string($ttl)) {
184
+        if (\is_string($ttl)){
185 185
             return (int)$ttl;
186 186
         }
187 187
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      */
196 196
     private function iterableToArray($iterable): array
197 197
     {
198
-        if (!is_iterable($iterable)) {
198
+        if (!is_iterable($iterable)){
199 199
             throw new \InvalidArgumentException(\sprintf('Iterable is expected, got %s.', \gettype($iterable)));
200 200
         }
201 201
         return $iterable instanceof Traversable ? \iterator_to_array($iterable) : $iterable;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
      */
207 207
     private function validateKey($key): void
208 208
     {
209
-        if (!\is_string($key) || $key === '' || \strpbrk($key, '{}()/\@:')) {
209
+        if (!\is_string($key) || $key === '' || \strpbrk($key, '{}()/\@:')){
210 210
             throw new \InvalidArgumentException('Invalid key value.');
211 211
         }
212 212
     }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     private function validateKeys(array $keys): void
218 218
     {
219 219
         /** @psalm-var mixed $key */
220
-        foreach ($keys as $key) {
220
+        foreach ($keys as $key){
221 221
             $this->validateKey($key);
222 222
         }
223 223
     }
Please login to merge, or discard this patch.
src/Cache/tests/Core/CacheInjectorTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
                     'test' => $this->defaultCache,
77 77
                     'array' => new ArrayCache(),
78 78
                 ][$name] ?? null;
79
-            if ($result === null) {
79
+            if ($result === null){
80 80
                 throw new NotFoundException();
81 81
             }
82 82
             return $result;
Please login to merge, or discard this patch.
src/Cache/src/Bootloader/CacheBootloader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     {
56 56
         $manager = new CacheManager($config, $container);
57 57
 
58
-        foreach ($config->getAliases() as $alias => $storageName) {
58
+        foreach ($config->getAliases() as $alias => $storageName){
59 59
             $container->bind($alias, static function (CacheManager $manager) use ($storageName) {
60 60
                 return $manager->storage($storageName);
61 61
             });
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                     ],
78 78
                     'file' => [
79 79
                         'type' => 'file',
80
-                        'path' => $dirs->get('runtime') . 'cache',
80
+                        'path' => $dirs->get('runtime').'cache',
81 81
                     ],
82 82
                 ],
83 83
                 'typeAliases' => [
Please login to merge, or discard this patch.
src/Cache/src/Core/CacheInjector.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,21 +25,21 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function createInjection(ReflectionClass $class, string $context = null): CacheInterface
27 27
     {
28
-        try {
29
-            if ($context === null) {
28
+        try{
29
+            if ($context === null){
30 30
                 $connection = $this->provider->storage();
31
-            } else {
31
+            }else{
32 32
                 // Get Cache by context
33
-                try {
33
+                try{
34 34
                     $connection = $this->provider->storage($context);
35
-                } catch (InvalidArgumentException $e) {
35
+                }catch (InvalidArgumentException $e){
36 36
                     // Case when context doesn't match to configured connections
37 37
                     return $this->provider->storage();
38 38
                 }
39 39
             }
40 40
 
41 41
             $this->matchType($class, $context, $connection);
42
-        } catch (\Throwable $e) {
42
+        }catch (\Throwable $e){
43 43
             throw new ContainerException(sprintf("Can't inject the required cache. %s", $e->getMessage()), 0, $e);
44 44
         }
45 45
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     private function matchType(ReflectionClass $class, ?string $context, CacheInterface $connection): void
55 55
     {
56 56
         $className = $class->getName();
57
-        if ($className !== CacheInterface::class && !$connection instanceof $className) {
57
+        if ($className !== CacheInterface::class && !$connection instanceof $className){
58 58
             throw new \RuntimeException(
59 59
                 \sprintf(
60 60
                     "The cache obtained by the context `%s` doesn't match the type `%s`.",
Please login to merge, or discard this patch.
src/Queue/src/Core/QueueInjector.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,21 +25,21 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function createInjection(ReflectionClass $class, string $context = null): QueueInterface
27 27
     {
28
-        try {
29
-            if ($context === null) {
28
+        try{
29
+            if ($context === null){
30 30
                 $connection = $this->queueManager->getConnection();
31
-            } else {
31
+            }else{
32 32
                 // Get Queue by context
33
-                try {
33
+                try{
34 34
                     $connection = $this->queueManager->getConnection($context);
35
-                } catch (InvalidArgumentException $e) {
35
+                }catch (InvalidArgumentException $e){
36 36
                     // Case when context doesn't match to configured connections
37 37
                     return $this->queueManager->getConnection();
38 38
                 }
39 39
             }
40 40
 
41 41
             $this->matchType($class, $context, $connection);
42
-        } catch (\Throwable $e) {
42
+        }catch (\Throwable $e){
43 43
             throw new ContainerException(sprintf("Can't inject the required queue. %s", $e->getMessage()), 0, $e);
44 44
         }
45 45
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     private function matchType(ReflectionClass $class, ?string $context, QueueInterface $connection): void
55 55
     {
56 56
         $className = $class->getName();
57
-        if ($className !== QueueInterface::class && !$connection instanceof $className) {
57
+        if ($className !== QueueInterface::class && !$connection instanceof $className){
58 58
             throw new \RuntimeException(
59 59
                 \sprintf(
60 60
                     "The queue obtained by the context `%s` doesn't match the type `%s`.",
Please login to merge, or discard this patch.