@@ -71,7 +71,7 @@ |
||
71 | 71 | */ |
72 | 72 | public function offsetGet($offset) |
73 | 73 | { |
74 | - if (!$this->offsetExists($offset)) { |
|
74 | + if (!$this->offsetExists($offset)){ |
|
75 | 75 | throw new ConfigException("Undefined configuration key '{$offset}'"); |
76 | 76 | } |
77 | 77 |
@@ -71,7 +71,8 @@ |
||
71 | 71 | */ |
72 | 72 | public function offsetGet($offset) |
73 | 73 | { |
74 | - if (!$this->offsetExists($offset)) { |
|
74 | + if (!$this->offsetExists($offset)) |
|
75 | + { |
|
75 | 76 | throw new ConfigException("Undefined configuration key '{$offset}'"); |
76 | 77 | } |
77 | 78 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | */ |
25 | 25 | public function resolveAlias(string $alias): string |
26 | 26 | { |
27 | - while (is_string($alias) && isset($this->config) && isset($this->config['aliases'][$alias])) { |
|
27 | + while (is_string($alias) && isset($this->config) && isset($this->config['aliases'][$alias])){ |
|
28 | 28 | $alias = $this->config['aliases'][$alias]; |
29 | 29 | } |
30 | 30 |
@@ -24,7 +24,8 @@ |
||
24 | 24 | */ |
25 | 25 | public function resolveAlias(string $alias): string |
26 | 26 | { |
27 | - while (is_string($alias) && isset($this->config) && isset($this->config['aliases'][$alias])) { |
|
27 | + while (is_string($alias) && isset($this->config) && isset($this->config['aliases'][$alias])) |
|
28 | + { |
|
28 | 29 | $alias = $this->config['aliases'][$alias]; |
29 | 30 | } |
30 | 31 |
@@ -58,22 +58,22 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function wire($definition): Autowire |
60 | 60 | { |
61 | - if ($definition instanceof self) { |
|
61 | + if ($definition instanceof self){ |
|
62 | 62 | return $definition; |
63 | 63 | } |
64 | 64 | |
65 | - if (is_string($definition)) { |
|
65 | + if (is_string($definition)){ |
|
66 | 66 | return new Autowire($definition); |
67 | 67 | } |
68 | 68 | |
69 | - if (is_array($definition) && isset($definition['class'])) { |
|
69 | + if (is_array($definition) && isset($definition['class'])){ |
|
70 | 70 | return new Autowire( |
71 | 71 | $definition['class'], |
72 | 72 | $definition['options'] ?? $definition['params'] ?? [] |
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
76 | - if (is_object($definition)) { |
|
76 | + if (is_object($definition)){ |
|
77 | 77 | $autowire = new self(get_class($definition), []); |
78 | 78 | $autowire->target = $definition; |
79 | 79 | return $autowire; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function resolve(FactoryInterface $factory, array $parameters = []) |
94 | 94 | { |
95 | - if ($this->target !== null) { |
|
95 | + if ($this->target !== null){ |
|
96 | 96 | // pre-wired |
97 | 97 | return $this->target; |
98 | 98 | } |
@@ -58,22 +58,26 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function wire($definition): Autowire |
60 | 60 | { |
61 | - if ($definition instanceof self) { |
|
61 | + if ($definition instanceof self) |
|
62 | + { |
|
62 | 63 | return $definition; |
63 | 64 | } |
64 | 65 | |
65 | - if (is_string($definition)) { |
|
66 | + if (is_string($definition)) |
|
67 | + { |
|
66 | 68 | return new Autowire($definition); |
67 | 69 | } |
68 | 70 | |
69 | - if (is_array($definition) && isset($definition['class'])) { |
|
71 | + if (is_array($definition) && isset($definition['class'])) |
|
72 | + { |
|
70 | 73 | return new Autowire( |
71 | 74 | $definition['class'], |
72 | 75 | $definition['options'] ?? $definition['params'] ?? [] |
73 | 76 | ); |
74 | 77 | } |
75 | 78 | |
76 | - if (is_object($definition)) { |
|
79 | + if (is_object($definition)) |
|
80 | + { |
|
77 | 81 | $autowire = new self(get_class($definition), []); |
78 | 82 | $autowire->target = $definition; |
79 | 83 | return $autowire; |
@@ -92,7 +96,8 @@ discard block |
||
92 | 96 | */ |
93 | 97 | public function resolve(FactoryInterface $factory, array $parameters = []) |
94 | 98 | { |
95 | - if ($this->target !== null) { |
|
99 | + if ($this->target !== null) |
|
100 | + { |
|
96 | 101 | // pre-wired |
97 | 102 | return $this->target; |
98 | 103 | } |
@@ -54,7 +54,8 @@ |
||
54 | 54 | return $source->withCode( |
55 | 55 | preg_replace_callback( |
56 | 56 | self::REGEXP, |
57 | - function ($matches) use ($domain, $context) { |
|
57 | + function ($matches) use ($domain, $context) |
|
58 | + { |
|
58 | 59 | return $this->translator->trans( |
59 | 60 | $matches[1], |
60 | 61 | [], |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | PermissionsInterface $permissions, |
42 | 42 | ContainerInterface $actorScope, |
43 | 43 | array $roles = [] |
44 | - ) { |
|
44 | + ){ |
|
45 | 45 | $this->roles = $roles; |
46 | 46 | $this->container = $actorScope; |
47 | 47 | $this->permissions = $permissions; |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | public function allows(string $permission, array $context = []): bool |
56 | 56 | { |
57 | 57 | $allows = false; |
58 | - foreach ($this->getRoles() as $role) { |
|
59 | - if (!$this->permissions->hasRole($role)) { |
|
58 | + foreach ($this->getRoles() as $role){ |
|
59 | + if (!$this->permissions->hasRole($role)){ |
|
60 | 60 | continue; |
61 | 61 | } |
62 | 62 | |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getActor(): ActorInterface |
105 | 105 | { |
106 | - if (!is_null($this->actor)) { |
|
106 | + if (!is_null($this->actor)){ |
|
107 | 107 | return $this->actor; |
108 | 108 | } |
109 | 109 | |
110 | - try { |
|
110 | + try{ |
|
111 | 111 | return $this->container->get(ActorInterface::class); |
112 | - } catch (NotFoundExceptionInterface $e) { |
|
112 | + }catch (NotFoundExceptionInterface $e){ |
|
113 | 113 | throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e); |
114 | 114 | } |
115 | 115 | } |
@@ -55,8 +55,10 @@ discard block |
||
55 | 55 | public function allows(string $permission, array $context = []): bool |
56 | 56 | { |
57 | 57 | $allows = false; |
58 | - foreach ($this->getRoles() as $role) { |
|
59 | - if (!$this->permissions->hasRole($role)) { |
|
58 | + foreach ($this->getRoles() as $role) |
|
59 | + { |
|
60 | + if (!$this->permissions->hasRole($role)) |
|
61 | + { |
|
60 | 62 | continue; |
61 | 63 | } |
62 | 64 | |
@@ -103,13 +105,17 @@ discard block |
||
103 | 105 | */ |
104 | 106 | public function getActor(): ActorInterface |
105 | 107 | { |
106 | - if (!is_null($this->actor)) { |
|
108 | + if (!is_null($this->actor)) |
|
109 | + { |
|
107 | 110 | return $this->actor; |
108 | 111 | } |
109 | 112 | |
110 | - try { |
|
113 | + try |
|
114 | + { |
|
111 | 115 | return $this->container->get(ActorInterface::class); |
112 | - } catch (NotFoundExceptionInterface $e) { |
|
116 | + } |
|
117 | + catch (NotFoundExceptionInterface $e) |
|
118 | + { |
|
113 | 119 | throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e); |
114 | 120 | } |
115 | 121 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | */ |
42 | 42 | public function getValue(string $source, string $name = null) |
43 | 43 | { |
44 | - if (!method_exists($this->input, $source)) { |
|
44 | + if (!method_exists($this->input, $source)){ |
|
45 | 45 | throw new InputException("Undefined input source '{$source}'"); |
46 | 46 | } |
47 | 47 |
@@ -41,7 +41,8 @@ |
||
41 | 41 | */ |
42 | 42 | public function getValue(string $source, string $name = null) |
43 | 43 | { |
44 | - if (!method_exists($this->input, $source)) { |
|
44 | + if (!method_exists($this->input, $source)) |
|
45 | + { |
|
45 | 46 | throw new InputException("Undefined input source '{$source}'"); |
46 | 47 | } |
47 | 48 |
@@ -42,13 +42,13 @@ |
||
42 | 42 | { |
43 | 43 | $schema = $this->orm->getSchema(); |
44 | 44 | |
45 | - foreach ($schema->getRoles() as $role) { |
|
45 | + foreach ($schema->getRoles() as $role){ |
|
46 | 46 | $repository = $schema->define($role, Schema::REPOSITORY); |
47 | 47 | |
48 | 48 | if ( |
49 | 49 | $repository !== Select\Repository::class |
50 | 50 | && $repository === $class->getName() |
51 | - ) { |
|
51 | + ){ |
|
52 | 52 | return $this->orm->getRepository($role); |
53 | 53 | } |
54 | 54 | } |
@@ -42,7 +42,8 @@ |
||
42 | 42 | { |
43 | 43 | $schema = $this->orm->getSchema(); |
44 | 44 | |
45 | - foreach ($schema->getRoles() as $role) { |
|
45 | + foreach ($schema->getRoles() as $role) |
|
46 | + { |
|
46 | 47 | $repository = $schema->define($role, Schema::REPOSITORY); |
47 | 48 | |
48 | 49 | if ( |
@@ -40,9 +40,9 @@ |
||
40 | 40 | public function renderException(Request $request, int $code, string $message): Response |
41 | 41 | { |
42 | 42 | $response = $this->responseFactory->createResponse($code); |
43 | - if ($request->getHeaderLine('Accept') == 'application/json') { |
|
43 | + if ($request->getHeaderLine('Accept') == 'application/json'){ |
|
44 | 44 | $response->getBody()->write(json_encode(['status' => $code, 'error' => $message])); |
45 | - } else { |
|
45 | + }else{ |
|
46 | 46 | $response->getBody()->write("Error code: {$code}"); |
47 | 47 | } |
48 | 48 |
@@ -40,9 +40,12 @@ |
||
40 | 40 | public function renderException(Request $request, int $code, string $message): Response |
41 | 41 | { |
42 | 42 | $response = $this->responseFactory->createResponse($code); |
43 | - if ($request->getHeaderLine('Accept') == 'application/json') { |
|
43 | + if ($request->getHeaderLine('Accept') == 'application/json') |
|
44 | + { |
|
44 | 45 | $response->getBody()->write(json_encode(['status' => $code, 'error' => $message])); |
45 | - } else { |
|
46 | + } |
|
47 | + else |
|
48 | + { |
|
46 | 49 | $response->getBody()->write("Error code: {$code}"); |
47 | 50 | } |
48 | 51 |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | $http = $this->container->get(Http::class); |
63 | 63 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
64 | 64 | |
65 | - try { |
|
65 | + try{ |
|
66 | 66 | $response = $http->handle($this->initRequest()); |
67 | 67 | $emitter->emit($response); |
68 | - } catch (\Throwable $e) { |
|
68 | + }catch (\Throwable $e){ |
|
69 | 69 | $this->handleException($emitter, $e); |
70 | - } finally { |
|
70 | + }finally{ |
|
71 | 71 | $this->finalizer->finalize(false); |
72 | 72 | } |
73 | 73 | } |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | { |
89 | 89 | $handler = new HtmlHandler(); |
90 | 90 | |
91 | - try { |
|
91 | + try{ |
|
92 | 92 | /** @var SnapshotInterface $snapshot */ |
93 | 93 | $this->container->get(SnapshotterInterface::class)->register($e); |
94 | 94 | |
95 | 95 | // on demand |
96 | 96 | $state = $this->container->get(StateInterface::class); |
97 | - if ($state !== null) { |
|
97 | + if ($state !== null){ |
|
98 | 98 | $handler = $handler->withState($state); |
99 | 99 | } |
100 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
100 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
101 | 101 | // nothing to report |
102 | 102 | } |
103 | 103 |
@@ -62,12 +62,17 @@ discard block |
||
62 | 62 | $http = $this->container->get(Http::class); |
63 | 63 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
64 | 64 | |
65 | - try { |
|
65 | + try |
|
66 | + { |
|
66 | 67 | $response = $http->handle($this->initRequest()); |
67 | 68 | $emitter->emit($response); |
68 | - } catch (\Throwable $e) { |
|
69 | + } |
|
70 | + catch (\Throwable $e) |
|
71 | + { |
|
69 | 72 | $this->handleException($emitter, $e); |
70 | - } finally { |
|
73 | + } |
|
74 | + finally |
|
75 | + { |
|
71 | 76 | $this->finalizer->finalize(false); |
72 | 77 | } |
73 | 78 | } |
@@ -88,16 +93,20 @@ discard block |
||
88 | 93 | { |
89 | 94 | $handler = new HtmlHandler(); |
90 | 95 | |
91 | - try { |
|
96 | + try |
|
97 | + { |
|
92 | 98 | /** @var SnapshotInterface $snapshot */ |
93 | 99 | $this->container->get(SnapshotterInterface::class)->register($e); |
94 | 100 | |
95 | 101 | // on demand |
96 | 102 | $state = $this->container->get(StateInterface::class); |
97 | - if ($state !== null) { |
|
103 | + if ($state !== null) |
|
104 | + { |
|
98 | 105 | $handler = $handler->withState($state); |
99 | 106 | } |
100 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
107 | + } |
|
108 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
109 | + { |
|
101 | 110 | // nothing to report |
102 | 111 | } |
103 | 112 |