@@ -21,7 +21,7 @@ |
||
| 21 | 21 | { |
| 22 | 22 | public function boot(EnvironmentInterface $env, BootloadManager $bootloadManager): void |
| 23 | 23 | { |
| 24 | - if ($env->get('CYCLE_AUTH')) { |
|
| 24 | + if ($env->get('CYCLE_AUTH')){ |
|
| 25 | 25 | $bootloadManager->bootload([CycleTokensBootloader::class]); |
| 26 | 26 | return; |
| 27 | 27 | } |
@@ -21,7 +21,8 @@ |
||
| 21 | 21 | { |
| 22 | 22 | public function boot(EnvironmentInterface $env, BootloadManager $bootloadManager): void |
| 23 | 23 | { |
| 24 | - if ($env->get('CYCLE_AUTH')) { |
|
| 24 | + if ($env->get('CYCLE_AUTH')) |
|
| 25 | + { |
|
| 25 | 26 | $bootloadManager->bootload([CycleTokensBootloader::class]); |
| 26 | 27 | return; |
| 27 | 28 | } |
@@ -40,18 +40,18 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function load(string $id): ?TokenInterface |
| 42 | 42 | { |
| 43 | - try { |
|
| 43 | + try{ |
|
| 44 | 44 | $tokenData = $this->session->getSection(self::SESSION_SECTION)->get('token'); |
| 45 | 45 | $token = Token::unpack($tokenData); |
| 46 | - } catch (\Throwable $e) { |
|
| 46 | + }catch (\Throwable $e){ |
|
| 47 | 47 | throw new TokenStorageException('Unable to load session token', $e->getCode(), $e); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if (!hash_equals($token->getID(), $id)) { |
|
| 50 | + if (!hash_equals($token->getID(), $id)){ |
|
| 51 | 51 | return null; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) { |
|
| 54 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()){ |
|
| 55 | 55 | $this->delete($token); |
| 56 | 56 | return null; |
| 57 | 57 | } |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
| 66 | 66 | { |
| 67 | - try { |
|
| 67 | + try{ |
|
| 68 | 68 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
| 69 | 69 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
| 70 | 70 | |
| 71 | 71 | return $token; |
| 72 | - } catch (\Throwable $e) { |
|
| 72 | + }catch (\Throwable $e){ |
|
| 73 | 73 | throw new TokenStorageException('Unable to create session token', $e->getCode(), $e); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -40,18 +40,23 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function load(string $id): ?TokenInterface |
| 42 | 42 | { |
| 43 | - try { |
|
| 43 | + try |
|
| 44 | + { |
|
| 44 | 45 | $tokenData = $this->session->getSection(self::SESSION_SECTION)->get('token'); |
| 45 | 46 | $token = Token::unpack($tokenData); |
| 46 | - } catch (\Throwable $e) { |
|
| 47 | + } |
|
| 48 | + catch (\Throwable $e) |
|
| 49 | + { |
|
| 47 | 50 | throw new TokenStorageException('Unable to load session token', $e->getCode(), $e); |
| 48 | 51 | } |
| 49 | 52 | |
| 50 | - if (!hash_equals($token->getID(), $id)) { |
|
| 53 | + if (!hash_equals($token->getID(), $id)) |
|
| 54 | + { |
|
| 51 | 55 | return null; |
| 52 | 56 | } |
| 53 | 57 | |
| 54 | - if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) { |
|
| 58 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) |
|
| 59 | + { |
|
| 55 | 60 | $this->delete($token); |
| 56 | 61 | return null; |
| 57 | 62 | } |
@@ -64,12 +69,15 @@ discard block |
||
| 64 | 69 | */ |
| 65 | 70 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
| 66 | 71 | { |
| 67 | - try { |
|
| 72 | + try |
|
| 73 | + { |
|
| 68 | 74 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
| 69 | 75 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
| 70 | 76 | |
| 71 | 77 | return $token; |
| 72 | - } catch (\Throwable $e) { |
|
| 78 | + } |
|
| 79 | + catch (\Throwable $e) |
|
| 80 | + { |
|
| 73 | 81 | throw new TokenStorageException('Unable to create session token', $e->getCode(), $e); |
| 74 | 82 | } |
| 75 | 83 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | array $payload, |
| 51 | 51 | \DateTimeImmutable $createdAt, |
| 52 | 52 | \DateTimeInterface $expiresAt = null |
| 53 | - ) { |
|
| 53 | + ){ |
|
| 54 | 54 | $this->id = $id; |
| 55 | 55 | |
| 56 | 56 | $this->secretValue = $secretValue; |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | |
| 44 | 44 | $memory->saveData('cycle', $schema); |
| 45 | 45 | |
| 46 | - if ($show->hasChanges()) { |
|
| 46 | + if ($show->hasChanges()){ |
|
| 47 | 47 | $this->writeln("\n<info>ORM Schema has been synchronized</info>"); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -43,7 +43,8 @@ |
||
| 43 | 43 | |
| 44 | 44 | $memory->saveData('cycle', $schema); |
| 45 | 45 | |
| 46 | - if ($show->hasChanges()) { |
|
| 46 | + if ($show->hasChanges()) |
|
| 47 | + { |
|
| 47 | 48 | $this->writeln("\n<info>ORM Schema has been synchronized</info>"); |
| 48 | 49 | } |
| 49 | 50 | } |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | public function getGenerators(): array |
| 86 | 86 | { |
| 87 | 87 | $result = []; |
| 88 | - foreach ($this->generators as $group) { |
|
| 89 | - foreach ($group as $generator) { |
|
| 90 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 88 | + foreach ($this->generators as $group){ |
|
| 89 | + foreach ($group as $generator){ |
|
| 90 | + if (is_object($generator) && !$generator instanceof Container\Autowire){ |
|
| 91 | 91 | $result[] = $generator; |
| 92 | - } else { |
|
| 92 | + }else{ |
|
| 93 | 93 | $result[] = $this->container->get($generator); |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | protected function schema(MemoryInterface $memory): SchemaInterface |
| 106 | 106 | { |
| 107 | 107 | $schema = $memory->loadData('cycle'); |
| 108 | - if (is_null($schema)) { |
|
| 108 | + if (is_null($schema)){ |
|
| 109 | 109 | $schema = (new Compiler())->compile( |
| 110 | 110 | $this->container->get(Registry::class), |
| 111 | 111 | $this->getGenerators() |
@@ -85,11 +85,16 @@ discard block |
||
| 85 | 85 | public function getGenerators(): array |
| 86 | 86 | { |
| 87 | 87 | $result = []; |
| 88 | - foreach ($this->generators as $group) { |
|
| 89 | - foreach ($group as $generator) { |
|
| 90 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 88 | + foreach ($this->generators as $group) |
|
| 89 | + { |
|
| 90 | + foreach ($group as $generator) |
|
| 91 | + { |
|
| 92 | + if (is_object($generator) && !$generator instanceof Container\Autowire) |
|
| 93 | + { |
|
| 91 | 94 | $result[] = $generator; |
| 92 | - } else { |
|
| 95 | + } |
|
| 96 | + else |
|
| 97 | + { |
|
| 93 | 98 | $result[] = $this->container->get($generator); |
| 94 | 99 | } |
| 95 | 100 | } |
@@ -105,7 +110,8 @@ discard block |
||
| 105 | 110 | protected function schema(MemoryInterface $memory): SchemaInterface |
| 106 | 111 | { |
| 107 | 112 | $schema = $memory->loadData('cycle'); |
| 108 | - if (is_null($schema)) { |
|
| 113 | + if (is_null($schema)) |
|
| 114 | + { |
|
| 109 | 115 | $schema = (new Compiler())->compile( |
| 110 | 116 | $this->container->get(Registry::class), |
| 111 | 117 | $this->getGenerators() |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public function boot(Container $container, FinalizerInterface $finalizer): void |
| 53 | 53 | { |
| 54 | 54 | $finalizer->addFinalizer(function () use ($container): void { |
| 55 | - if ($container->hasInstance(ORMInterface::class)) { |
|
| 55 | + if ($container->hasInstance(ORMInterface::class)){ |
|
| 56 | 56 | $container->get(ORMInterface::class)->getHeap()->clean(); |
| 57 | 57 | } |
| 58 | 58 | }); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | ): ORMInterface { |
| 74 | 74 | $orm = new ORM($factory, $schema); |
| 75 | 75 | |
| 76 | - if ($promiseFactory !== null) { |
|
| 76 | + if ($promiseFactory !== null){ |
|
| 77 | 77 | return $orm->withPromiseFactory($promiseFactory); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -52,7 +52,8 @@ discard block |
||
| 52 | 52 | public function boot(Container $container, FinalizerInterface $finalizer): void |
| 53 | 53 | { |
| 54 | 54 | $finalizer->addFinalizer(function () use ($container): void { |
| 55 | - if ($container->hasInstance(ORMInterface::class)) { |
|
| 55 | + if ($container->hasInstance(ORMInterface::class)) |
|
| 56 | + { |
|
| 56 | 57 | $container->get(ORMInterface::class)->getHeap()->clean(); |
| 57 | 58 | } |
| 58 | 59 | }); |
@@ -73,7 +74,8 @@ discard block |
||
| 73 | 74 | ): ORMInterface { |
| 74 | 75 | $orm = new ORM($factory, $schema); |
| 75 | 76 | |
| 76 | - if ($promiseFactory !== null) { |
|
| 77 | + if ($promiseFactory !== null) |
|
| 78 | + { |
|
| 77 | 79 | return $orm->withPromiseFactory($promiseFactory); |
| 78 | 80 | } |
| 79 | 81 | |
@@ -38,9 +38,9 @@ |
||
| 38 | 38 | public function createInjection(\ReflectionClass $class, string $context = null) |
| 39 | 39 | { |
| 40 | 40 | $schema = $this->orm->getSchema(); |
| 41 | - foreach ($schema->getRoles() as $role) { |
|
| 41 | + foreach ($schema->getRoles() as $role){ |
|
| 42 | 42 | $repository = $schema->define($role, Schema::REPOSITORY); |
| 43 | - if ($repository !== Select\Repository::class && $repository === $class->getName()) { |
|
| 43 | + if ($repository !== Select\Repository::class && $repository === $class->getName()){ |
|
| 44 | 44 | return $this->orm->getRepository($role); |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -38,9 +38,11 @@ |
||
| 38 | 38 | public function createInjection(\ReflectionClass $class, string $context = null) |
| 39 | 39 | { |
| 40 | 40 | $schema = $this->orm->getSchema(); |
| 41 | - foreach ($schema->getRoles() as $role) { |
|
| 41 | + foreach ($schema->getRoles() as $role) |
|
| 42 | + { |
|
| 42 | 43 | $repository = $schema->define($role, Schema::REPOSITORY); |
| 43 | - if ($repository !== Select\Repository::class && $repository === $class->getName()) { |
|
| 44 | + if ($repository !== Select\Repository::class && $repository === $class->getName()) |
|
| 45 | + { |
|
| 44 | 46 | return $this->orm->getRepository($role); |
| 45 | 47 | } |
| 46 | 48 | } |
@@ -29,9 +29,9 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
| 31 | 31 | { |
| 32 | - if ($this->isJsonPayload($request)) { |
|
| 32 | + if ($this->isJsonPayload($request)){ |
|
| 33 | 33 | $request = $request->withParsedBody(json_decode((string)$request->getBody(), true)); |
| 34 | - if (json_last_error() !== 0) { |
|
| 34 | + if (json_last_error() !== 0){ |
|
| 35 | 35 | throw new ClientException(400, 'invalid json payload'); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -29,9 +29,11 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
| 31 | 31 | { |
| 32 | - if ($this->isJsonPayload($request)) { |
|
| 32 | + if ($this->isJsonPayload($request)) |
|
| 33 | + { |
|
| 33 | 34 | $request = $request->withParsedBody(json_decode((string)$request->getBody(), true)); |
| 34 | - if (json_last_error() !== 0) { |
|
| 35 | + if (json_last_error() !== 0) |
|
| 36 | + { |
|
| 35 | 37 | throw new ClientException(400, 'invalid json payload'); |
| 36 | 38 | } |
| 37 | 39 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | |
| 49 | 49 | public function input(InputScope $i) |
| 50 | 50 | { |
| 51 | - return 'value: ' . $i->withPrefix('section')->getValue('query', 'value'); |
|
| 51 | + return 'value: '.$i->withPrefix('section')->getValue('query', 'value'); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function error(): void |