@@ -55,8 +55,10 @@ |
||
55 | 55 | { |
56 | 56 | $manager = new CacheManager($config, $container); |
57 | 57 | |
58 | - foreach ($config->getAliases() as $alias => $storageName) { |
|
59 | - $container->bind($alias, static function (CacheManager $manager) use ($storageName) { |
|
58 | + foreach ($config->getAliases() as $alias => $storageName) |
|
59 | + { |
|
60 | + $container->bind($alias, static function (CacheManager $manager) use ($storageName) |
|
61 | + { |
|
60 | 62 | return $manager->storage($storageName); |
61 | 63 | }); |
62 | 64 | } |
@@ -25,21 +25,30 @@ discard block |
||
25 | 25 | |
26 | 26 | public function createInjection(ReflectionClass $class, string $context = null): CacheInterface |
27 | 27 | { |
28 | - try { |
|
29 | - if ($context === null) { |
|
28 | + try |
|
29 | + { |
|
30 | + if ($context === null) |
|
31 | + { |
|
30 | 32 | $connection = $this->provider->storage(); |
31 | - } else { |
|
33 | + } |
|
34 | + else |
|
35 | + { |
|
32 | 36 | // Get Cache by context |
33 | - try { |
|
37 | + try |
|
38 | + { |
|
34 | 39 | $connection = $this->provider->storage($context); |
35 | - } catch (InvalidArgumentException $e) { |
|
40 | + } |
|
41 | + catch (InvalidArgumentException $e) |
|
42 | + { |
|
36 | 43 | // Case when context doesn't match to configured connections |
37 | 44 | return $this->provider->storage(); |
38 | 45 | } |
39 | 46 | } |
40 | 47 | |
41 | 48 | $this->matchType($class, $context, $connection); |
42 | - } catch (\Throwable $e) { |
|
49 | + } |
|
50 | + catch (\Throwable $e) |
|
51 | + { |
|
43 | 52 | throw new ContainerException(sprintf("Can't inject the required cache. %s", $e->getMessage()), 0, $e); |
44 | 53 | } |
45 | 54 | |
@@ -54,7 +63,8 @@ discard block |
||
54 | 63 | private function matchType(ReflectionClass $class, ?string $context, CacheInterface $connection): void |
55 | 64 | { |
56 | 65 | $className = $class->getName(); |
57 | - if ($className !== CacheInterface::class && !$connection instanceof $className) { |
|
66 | + if ($className !== CacheInterface::class && !$connection instanceof $className) |
|
67 | + { |
|
58 | 68 | throw new \RuntimeException( |
59 | 69 | \sprintf( |
60 | 70 | "The cache obtained by the context `%s` doesn't match the type `%s`.", |
@@ -25,21 +25,30 @@ discard block |
||
25 | 25 | |
26 | 26 | public function createInjection(ReflectionClass $class, string $context = null): QueueInterface |
27 | 27 | { |
28 | - try { |
|
29 | - if ($context === null) { |
|
28 | + try |
|
29 | + { |
|
30 | + if ($context === null) |
|
31 | + { |
|
30 | 32 | $connection = $this->queueManager->getConnection(); |
31 | - } else { |
|
33 | + } |
|
34 | + else |
|
35 | + { |
|
32 | 36 | // Get Queue by context |
33 | - try { |
|
37 | + try |
|
38 | + { |
|
34 | 39 | $connection = $this->queueManager->getConnection($context); |
35 | - } catch (InvalidArgumentException $e) { |
|
40 | + } |
|
41 | + catch (InvalidArgumentException $e) |
|
42 | + { |
|
36 | 43 | // Case when context doesn't match to configured connections |
37 | 44 | return $this->queueManager->getConnection(); |
38 | 45 | } |
39 | 46 | } |
40 | 47 | |
41 | 48 | $this->matchType($class, $context, $connection); |
42 | - } catch (\Throwable $e) { |
|
49 | + } |
|
50 | + catch (\Throwable $e) |
|
51 | + { |
|
43 | 52 | throw new ContainerException(sprintf("Can't inject the required queue. %s", $e->getMessage()), 0, $e); |
44 | 53 | } |
45 | 54 | |
@@ -54,7 +63,8 @@ discard block |
||
54 | 63 | private function matchType(ReflectionClass $class, ?string $context, QueueInterface $connection): void |
55 | 64 | { |
56 | 65 | $className = $class->getName(); |
57 | - if ($className !== QueueInterface::class && !$connection instanceof $className) { |
|
66 | + if ($className !== QueueInterface::class && !$connection instanceof $className) |
|
67 | + { |
|
58 | 68 | throw new \RuntimeException( |
59 | 69 | \sprintf( |
60 | 70 | "The queue obtained by the context `%s` doesn't match the type `%s`.", |
@@ -76,7 +76,8 @@ |
||
76 | 76 | 'test' => $this->defaultCache, |
77 | 77 | 'array' => new ArrayStorage(), |
78 | 78 | ][$name] ?? null; |
79 | - if ($result === null) { |
|
79 | + if ($result === null) |
|
80 | + { |
|
80 | 81 | throw new NotFoundException(); |
81 | 82 | } |
82 | 83 | return $result; |