@@ -44,8 +44,8 @@ |
||
| 44 | 44 | $this->context = $context; |
| 45 | 45 | |
| 46 | 46 | $name = $context->getName(); |
| 47 | - if ($context instanceof ReflectionMethod) { |
|
| 48 | - $name = $context->class . '::' . $name; |
|
| 47 | + if ($context instanceof ReflectionMethod){ |
|
| 48 | + $name = $context->class.'::'.$name; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | parent::__construct("Unable to resolve '{$parameter->name}' argument in '{$name}'"); |
@@ -44,7 +44,8 @@ |
||
| 44 | 44 | $this->context = $context; |
| 45 | 45 | |
| 46 | 46 | $name = $context->getName(); |
| 47 | - if ($context instanceof ReflectionMethod) { |
|
| 47 | + if ($context instanceof ReflectionMethod) |
|
| 48 | + { |
|
| 48 | 49 | $name = $context->class . '::' . $name; |
| 49 | 50 | } |
| 50 | 51 | |
@@ -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 | |