| @@ -123,9 +123,9 @@ | ||
| 123 | 123 | */ | 
| 124 | 124 | public function getActiveSession(): SessionInterface | 
| 125 | 125 |      { | 
| 126 | -        try { | |
| 126 | +        try{ | |
| 127 | 127 | return $this->container->get(SessionInterface::class); | 
| 128 | -        } catch (NotFoundExceptionInterface $e) { | |
| 128 | +        }catch (NotFoundExceptionInterface $e){ | |
| 129 | 129 |              throw new ScopeException('Unable to receive active session, invalid request scope', $e->getCode(), $e); | 
| 130 | 130 | } | 
| 131 | 131 | } | 
| @@ -123,9 +123,12 @@ | ||
| 123 | 123 | */ | 
| 124 | 124 | public function getActiveSession(): SessionInterface | 
| 125 | 125 |      { | 
| 126 | -        try { | |
| 126 | + try | |
| 127 | +        { | |
| 127 | 128 | return $this->container->get(SessionInterface::class); | 
| 128 | -        } catch (NotFoundExceptionInterface $e) { | |
| 129 | + } | |
| 130 | + catch (NotFoundExceptionInterface $e) | |
| 131 | +        { | |
| 129 | 132 |              throw new ScopeException('Unable to receive active session, invalid request scope', $e->getCode(), $e); | 
| 130 | 133 | } | 
| 131 | 134 | } | 
| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | string $domain = null, | 
| 119 | 119 | bool $secure = null, | 
| 120 | 120 | bool $httpOnly = true | 
| 121 | -    ) { | |
| 121 | +    ){ | |
| 122 | 122 | $this->getCookieQueue()->set($name, $value, $lifetime, $path, $domain, $secure, $httpOnly); | 
| 123 | 123 | |
| 124 | 124 | return $this; | 
| @@ -169,9 +169,9 @@ discard block | ||
| 169 | 169 | */ | 
| 170 | 170 | private function getRequest(): ServerRequestInterface | 
| 171 | 171 |      { | 
| 172 | -        try { | |
| 172 | +        try{ | |
| 173 | 173 | return $this->container->get(ServerRequestInterface::class); | 
| 174 | -        } catch (NotFoundExceptionInterface $e) { | |
| 174 | +        }catch (NotFoundExceptionInterface $e){ | |
| 175 | 175 |              throw new ScopeException('Unable to receive active request', $e->getCode(), $e); | 
| 176 | 176 | } | 
| 177 | 177 | } | 
| @@ -183,9 +183,9 @@ discard block | ||
| 183 | 183 | */ | 
| 184 | 184 | private function getCookieQueue(): CookieQueue | 
| 185 | 185 |      { | 
| 186 | -        try { | |
| 186 | +        try{ | |
| 187 | 187 | return $this->container->get(CookieQueue::class); | 
| 188 | -        } catch (NotFoundExceptionInterface $e) { | |
| 188 | +        }catch (NotFoundExceptionInterface $e){ | |
| 189 | 189 |              throw new ScopeException('Unable to receive cookie queue, invalid request scope', $e->getCode(), $e); | 
| 190 | 190 | } | 
| 191 | 191 | } | 
| @@ -169,9 +169,12 @@ discard block | ||
| 169 | 169 | */ | 
| 170 | 170 | private function getRequest(): ServerRequestInterface | 
| 171 | 171 |      { | 
| 172 | -        try { | |
| 172 | + try | |
| 173 | +        { | |
| 173 | 174 | return $this->container->get(ServerRequestInterface::class); | 
| 174 | -        } catch (NotFoundExceptionInterface $e) { | |
| 175 | + } | |
| 176 | + catch (NotFoundExceptionInterface $e) | |
| 177 | +        { | |
| 175 | 178 |              throw new ScopeException('Unable to receive active request', $e->getCode(), $e); | 
| 176 | 179 | } | 
| 177 | 180 | } | 
| @@ -183,9 +186,12 @@ discard block | ||
| 183 | 186 | */ | 
| 184 | 187 | private function getCookieQueue(): CookieQueue | 
| 185 | 188 |      { | 
| 186 | -        try { | |
| 189 | + try | |
| 190 | +        { | |
| 187 | 191 | return $this->container->get(CookieQueue::class); | 
| 188 | -        } catch (NotFoundExceptionInterface $e) { | |
| 192 | + } | |
| 193 | + catch (NotFoundExceptionInterface $e) | |
| 194 | +        { | |
| 189 | 195 |              throw new ScopeException('Unable to receive cookie queue, invalid request scope', $e->getCode(), $e); | 
| 190 | 196 | } | 
| 191 | 197 | } | 
| @@ -50,8 +50,8 @@ discard block | ||
| 50 | 50 | */ | 
| 51 | 51 | public function getActor(TokenInterface $token): ?object | 
| 52 | 52 |      { | 
| 53 | -        foreach ($this->getProviders() as $provider) { | |
| 54 | -            if (!$provider instanceof ActorProviderInterface) { | |
| 53 | +        foreach ($this->getProviders() as $provider){ | |
| 54 | +            if (!$provider instanceof ActorProviderInterface){ | |
| 55 | 55 | throw new AuthException(sprintf( | 
| 56 | 56 | "Expected `ActorProviderInterface`, got `%s`", | 
| 57 | 57 | get_class($provider) | 
| @@ -59,7 +59,7 @@ discard block | ||
| 59 | 59 | } | 
| 60 | 60 | |
| 61 | 61 | $actor = $provider->getActor($token); | 
| 62 | -            if ($actor !== null) { | |
| 62 | +            if ($actor !== null){ | |
| 63 | 63 | return $actor; | 
| 64 | 64 | } | 
| 65 | 65 | } | 
| @@ -82,13 +82,13 @@ discard block | ||
| 82 | 82 | */ | 
| 83 | 83 | private function getProviders(): \Generator | 
| 84 | 84 |      { | 
| 85 | -        foreach ($this->actorProvider as $provider) { | |
| 86 | -            if ($provider instanceof Autowire) { | |
| 85 | +        foreach ($this->actorProvider as $provider){ | |
| 86 | +            if ($provider instanceof Autowire){ | |
| 87 | 87 | yield $provider->resolve($this->factory); | 
| 88 | 88 | continue; | 
| 89 | 89 | } | 
| 90 | 90 | |
| 91 | -            if (is_object($provider)) { | |
| 91 | +            if (is_object($provider)){ | |
| 92 | 92 | yield $provider; | 
| 93 | 93 | continue; | 
| 94 | 94 | } | 
| @@ -50,8 +50,10 @@ discard block | ||
| 50 | 50 | */ | 
| 51 | 51 | public function getActor(TokenInterface $token): ?object | 
| 52 | 52 |      { | 
| 53 | -        foreach ($this->getProviders() as $provider) { | |
| 54 | -            if (!$provider instanceof ActorProviderInterface) { | |
| 53 | + foreach ($this->getProviders() as $provider) | |
| 54 | +        { | |
| 55 | + if (!$provider instanceof ActorProviderInterface) | |
| 56 | +            { | |
| 55 | 57 | throw new AuthException(sprintf( | 
| 56 | 58 | "Expected `ActorProviderInterface`, got `%s`", | 
| 57 | 59 | get_class($provider) | 
| @@ -59,7 +61,8 @@ discard block | ||
| 59 | 61 | } | 
| 60 | 62 | |
| 61 | 63 | $actor = $provider->getActor($token); | 
| 62 | -            if ($actor !== null) { | |
| 64 | + if ($actor !== null) | |
| 65 | +            { | |
| 63 | 66 | return $actor; | 
| 64 | 67 | } | 
| 65 | 68 | } | 
| @@ -82,13 +85,16 @@ discard block | ||
| 82 | 85 | */ | 
| 83 | 86 | private function getProviders(): \Generator | 
| 84 | 87 |      { | 
| 85 | -        foreach ($this->actorProvider as $provider) { | |
| 86 | -            if ($provider instanceof Autowire) { | |
| 88 | + foreach ($this->actorProvider as $provider) | |
| 89 | +        { | |
| 90 | + if ($provider instanceof Autowire) | |
| 91 | +            { | |
| 87 | 92 | yield $provider->resolve($this->factory); | 
| 88 | 93 | continue; | 
| 89 | 94 | } | 
| 90 | 95 | |
| 91 | -            if (is_object($provider)) { | |
| 96 | + if (is_object($provider)) | |
| 97 | +            { | |
| 92 | 98 | yield $provider; | 
| 93 | 99 | continue; | 
| 94 | 100 | } | 
| @@ -42,19 +42,19 @@ discard block | ||
| 42 | 42 | */ | 
| 43 | 43 | public function load(string $id): ?TokenInterface | 
| 44 | 44 |      { | 
| 45 | -        try { | |
| 45 | +        try{ | |
| 46 | 46 |              $tokenData = $this->getAuthSection()->get('token'); | 
| 47 | 47 | $token = Token::unpack($tokenData); | 
| 48 | 48 | |
| 49 | -        } catch (\Throwable $e) { | |
| 49 | +        }catch (\Throwable $e){ | |
| 50 | 50 |              throw new TokenStorageException("Unable to load session token", $e->getCode(), $e); | 
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | -        if ($token->getID() !== $id) { | |
| 53 | +        if ($token->getID() !== $id){ | |
| 54 | 54 | return null; | 
| 55 | 55 | } | 
| 56 | 56 | |
| 57 | -        if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) { | |
| 57 | +        if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()){ | |
| 58 | 58 | $this->delete($token); | 
| 59 | 59 | return null; | 
| 60 | 60 | } | 
| @@ -67,12 +67,12 @@ discard block | ||
| 67 | 67 | */ | 
| 68 | 68 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface | 
| 69 | 69 |      { | 
| 70 | -        try { | |
| 70 | +        try{ | |
| 71 | 71 | $token = new Token($this->randomHash(123), $payload, $expiresAt); | 
| 72 | 72 |              $this->getAuthSection()->set('token', $token->pack()); | 
| 73 | 73 | |
| 74 | 74 | return $token; | 
| 75 | -        } catch (\Throwable $e) { | |
| 75 | +        }catch (\Throwable $e){ | |
| 76 | 76 |              throw new TokenStorageException("Unable to create session token", $e->getCode(), $e); | 
| 77 | 77 | } | 
| 78 | 78 | } | 
| @@ -90,12 +90,12 @@ discard block | ||
| 90 | 90 | */ | 
| 91 | 91 | private function getAuthSection(): SessionSectionInterface | 
| 92 | 92 |      { | 
| 93 | -        try { | |
| 93 | +        try{ | |
| 94 | 94 | $session = $this->container->get(SessionInterface::class); | 
| 95 | 95 | |
| 96 | 96 | /** @var SessionInterface $session */ | 
| 97 | 97 | return $session->getSection(self::SESSION_SECTION); | 
| 98 | -        } catch (ContainerExceptionInterface $e) { | |
| 98 | +        }catch (ContainerExceptionInterface $e){ | |
| 99 | 99 |              throw new ScopeException("Unable to find auth token, invalid session scope", $e->getCode(), $e); | 
| 100 | 100 | } | 
| 101 | 101 | } | 
| @@ -42,19 +42,24 @@ discard block | ||
| 42 | 42 | */ | 
| 43 | 43 | public function load(string $id): ?TokenInterface | 
| 44 | 44 |      { | 
| 45 | -        try { | |
| 45 | + try | |
| 46 | +        { | |
| 46 | 47 |              $tokenData = $this->getAuthSection()->get('token'); | 
| 47 | 48 | $token = Token::unpack($tokenData); | 
| 48 | 49 | |
| 49 | -        } catch (\Throwable $e) { | |
| 50 | + } | |
| 51 | + catch (\Throwable $e) | |
| 52 | +        { | |
| 50 | 53 |              throw new TokenStorageException("Unable to load session token", $e->getCode(), $e); | 
| 51 | 54 | } | 
| 52 | 55 | |
| 53 | -        if ($token->getID() !== $id) { | |
| 56 | + if ($token->getID() !== $id) | |
| 57 | +        { | |
| 54 | 58 | return null; | 
| 55 | 59 | } | 
| 56 | 60 | |
| 57 | -        if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) { | |
| 61 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) | |
| 62 | +        { | |
| 58 | 63 | $this->delete($token); | 
| 59 | 64 | return null; | 
| 60 | 65 | } | 
| @@ -67,12 +72,15 @@ discard block | ||
| 67 | 72 | */ | 
| 68 | 73 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface | 
| 69 | 74 |      { | 
| 70 | -        try { | |
| 75 | + try | |
| 76 | +        { | |
| 71 | 77 | $token = new Token($this->randomHash(123), $payload, $expiresAt); | 
| 72 | 78 |              $this->getAuthSection()->set('token', $token->pack()); | 
| 73 | 79 | |
| 74 | 80 | return $token; | 
| 75 | -        } catch (\Throwable $e) { | |
| 81 | + } | |
| 82 | + catch (\Throwable $e) | |
| 83 | +        { | |
| 76 | 84 |              throw new TokenStorageException("Unable to create session token", $e->getCode(), $e); | 
| 77 | 85 | } | 
| 78 | 86 | } | 
| @@ -90,12 +98,15 @@ discard block | ||
| 90 | 98 | */ | 
| 91 | 99 | private function getAuthSection(): SessionSectionInterface | 
| 92 | 100 |      { | 
| 93 | -        try { | |
| 101 | + try | |
| 102 | +        { | |
| 94 | 103 | $session = $this->container->get(SessionInterface::class); | 
| 95 | 104 | |
| 96 | 105 | /** @var SessionInterface $session */ | 
| 97 | 106 | return $session->getSection(self::SESSION_SECTION); | 
| 98 | -        } catch (ContainerExceptionInterface $e) { | |
| 107 | + } | |
| 108 | + catch (ContainerExceptionInterface $e) | |
| 109 | +        { | |
| 99 | 110 |              throw new ScopeException("Unable to find auth token, invalid session scope", $e->getCode(), $e); | 
| 100 | 111 | } | 
| 101 | 112 | } | 
| @@ -98,7 +98,7 @@ | ||
| 98 | 98 | public static function unpack(array $data): Token | 
| 99 | 99 |      { | 
| 100 | 100 | $expiresAt = null; | 
| 101 | -        if ($data['expiredAt'] != null) { | |
| 101 | +        if ($data['expiredAt'] != null){ | |
| 102 | 102 | $expiresAt = (new \DateTimeImmutable())->setTimestamp($data['expiredAt']); | 
| 103 | 103 | } | 
| 104 | 104 | |
| @@ -98,7 +98,8 @@ | ||
| 98 | 98 | public static function unpack(array $data): Token | 
| 99 | 99 |      { | 
| 100 | 100 | $expiresAt = null; | 
| 101 | -        if ($data['expiredAt'] != null) { | |
| 101 | + if ($data['expiredAt'] != null) | |
| 102 | +        { | |
| 102 | 103 | $expiresAt = (new \DateTimeImmutable())->setTimestamp($data['expiredAt']); | 
| 103 | 104 | } | 
| 104 | 105 | |
| @@ -40,25 +40,25 @@ discard block | ||
| 40 | 40 | */ | 
| 41 | 41 | public function load(string $id): ?TokenInterface | 
| 42 | 42 |      { | 
| 43 | -        if (strpos($id, ':') === false) { | |
| 43 | +        if (strpos($id, ':') === false){ | |
| 44 | 44 | return null; | 
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | 47 |          list($pk, $hash) = explode(':', $id, 2); | 
| 48 | 48 | |
| 49 | -        if (!is_numeric($id)) { | |
| 49 | +        if (!is_numeric($id)){ | |
| 50 | 50 | return null; | 
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | 53 | /** @var TokenInterface $token */ | 
| 54 | 54 | $token = $this->findByPK((int)$pk); | 
| 55 | 55 | |
| 56 | -        if ($token === null || $token->getID() !== $id) { | |
| 56 | +        if ($token === null || $token->getID() !== $id){ | |
| 57 | 57 | // hijacked or deleted | 
| 58 | 58 | return null; | 
| 59 | 59 | } | 
| 60 | 60 | |
| 61 | -        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) { | |
| 61 | +        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()){ | |
| 62 | 62 | $this->delete($token); | 
| 63 | 63 | return null; | 
| 64 | 64 | } | 
| @@ -71,13 +71,13 @@ discard block | ||
| 71 | 71 | */ | 
| 72 | 72 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface | 
| 73 | 73 |      { | 
| 74 | -        try { | |
| 74 | +        try{ | |
| 75 | 75 | $token = new Token($this->randomHash(128), $payload, new \DateTimeImmutable(), $expiresAt); | 
| 76 | 76 | |
| 77 | 77 | (new Transaction($this->orm))->persist($token)->run(); | 
| 78 | 78 | |
| 79 | 79 | return $token; | 
| 80 | -        } catch (\Throwable $e) { | |
| 80 | +        }catch (\Throwable $e){ | |
| 81 | 81 |              throw new TokenStorageException("Unable to create token", $e->getCode(), $e); | 
| 82 | 82 | } | 
| 83 | 83 | } | 
| @@ -87,9 +87,9 @@ discard block | ||
| 87 | 87 | */ | 
| 88 | 88 | public function delete(TokenInterface $token): void | 
| 89 | 89 |      { | 
| 90 | -        try { | |
| 90 | +        try{ | |
| 91 | 91 | (new Transaction($this->orm))->delete($token)->run(); | 
| 92 | -        } catch (\Throwable $e) { | |
| 92 | +        }catch (\Throwable $e){ | |
| 93 | 93 |              throw new TokenStorageException("Unable to delete token", $e->getCode(), $e); | 
| 94 | 94 | } | 
| 95 | 95 | } | 
| @@ -40,25 +40,29 @@ discard block | ||
| 40 | 40 | */ | 
| 41 | 41 | public function load(string $id): ?TokenInterface | 
| 42 | 42 |      { | 
| 43 | -        if (strpos($id, ':') === false) { | |
| 43 | + if (strpos($id, ':') === false) | |
| 44 | +        { | |
| 44 | 45 | return null; | 
| 45 | 46 | } | 
| 46 | 47 | |
| 47 | 48 |          list($pk, $hash) = explode(':', $id, 2); | 
| 48 | 49 | |
| 49 | -        if (!is_numeric($id)) { | |
| 50 | + if (!is_numeric($id)) | |
| 51 | +        { | |
| 50 | 52 | return null; | 
| 51 | 53 | } | 
| 52 | 54 | |
| 53 | 55 | /** @var TokenInterface $token */ | 
| 54 | 56 | $token = $this->findByPK((int)$pk); | 
| 55 | 57 | |
| 56 | -        if ($token === null || $token->getID() !== $id) { | |
| 58 | + if ($token === null || $token->getID() !== $id) | |
| 59 | +        { | |
| 57 | 60 | // hijacked or deleted | 
| 58 | 61 | return null; | 
| 59 | 62 | } | 
| 60 | 63 | |
| 61 | -        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) { | |
| 64 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) | |
| 65 | +        { | |
| 62 | 66 | $this->delete($token); | 
| 63 | 67 | return null; | 
| 64 | 68 | } | 
| @@ -71,13 +75,16 @@ discard block | ||
| 71 | 75 | */ | 
| 72 | 76 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface | 
| 73 | 77 |      { | 
| 74 | -        try { | |
| 78 | + try | |
| 79 | +        { | |
| 75 | 80 | $token = new Token($this->randomHash(128), $payload, new \DateTimeImmutable(), $expiresAt); | 
| 76 | 81 | |
| 77 | 82 | (new Transaction($this->orm))->persist($token)->run(); | 
| 78 | 83 | |
| 79 | 84 | return $token; | 
| 80 | -        } catch (\Throwable $e) { | |
| 85 | + } | |
| 86 | + catch (\Throwable $e) | |
| 87 | +        { | |
| 81 | 88 |              throw new TokenStorageException("Unable to create token", $e->getCode(), $e); | 
| 82 | 89 | } | 
| 83 | 90 | } | 
| @@ -87,9 +94,12 @@ discard block | ||
| 87 | 94 | */ | 
| 88 | 95 | public function delete(TokenInterface $token): void | 
| 89 | 96 |      { | 
| 90 | -        try { | |
| 97 | + try | |
| 98 | +        { | |
| 91 | 99 | (new Transaction($this->orm))->delete($token)->run(); | 
| 92 | -        } catch (\Throwable $e) { | |
| 100 | + } | |
| 101 | + catch (\Throwable $e) | |
| 102 | +        { | |
| 93 | 103 |              throw new TokenStorageException("Unable to delete token", $e->getCode(), $e); | 
| 94 | 104 | } | 
| 95 | 105 | } | 
| @@ -46,7 +46,7 @@ | ||
| 46 | 46 | array $payload, | 
| 47 | 47 | \DateTimeImmutable $createdAt, | 
| 48 | 48 | \DateTimeInterface $expiresAt = null | 
| 49 | -    ) { | |
| 49 | +    ){ | |
| 50 | 50 | $this->hash = $hash; | 
| 51 | 51 | $this->createdAt = $createdAt; | 
| 52 | 52 | $this->expiresAt = $expiresAt; | 
| @@ -94,9 +94,9 @@ | ||
| 94 | 94 | */ | 
| 95 | 95 | private function getAuthContext(): AuthContextInterface | 
| 96 | 96 |      { | 
| 97 | -        try { | |
| 97 | +        try{ | |
| 98 | 98 | return $this->container->get(AuthContextInterface::class); | 
| 99 | -        } catch (NotFoundExceptionInterface $e) { | |
| 99 | +        }catch (NotFoundExceptionInterface $e){ | |
| 100 | 100 |              throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); | 
| 101 | 101 | } | 
| 102 | 102 | } | 
| @@ -94,9 +94,12 @@ | ||
| 94 | 94 | */ | 
| 95 | 95 | private function getAuthContext(): AuthContextInterface | 
| 96 | 96 |      { | 
| 97 | -        try { | |
| 97 | + try | |
| 98 | +        { | |
| 98 | 99 | return $this->container->get(AuthContextInterface::class); | 
| 99 | -        } catch (NotFoundExceptionInterface $e) { | |
| 100 | + } | |
| 101 | + catch (NotFoundExceptionInterface $e) | |
| 102 | +        { | |
| 100 | 103 |              throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); | 
| 101 | 104 | } | 
| 102 | 105 | } | 
| @@ -52,15 +52,15 @@ | ||
| 52 | 52 | public function getUser(string $username, string $password): PasswordAwareInterface | 
| 53 | 53 |      { | 
| 54 | 54 | $user = $this->source->findByUsername($username); | 
| 55 | -        if (empty($user)) { | |
| 55 | +        if (empty($user)){ | |
| 56 | 56 |              throw new CredentialsException("Unable to authorize, no such user"); | 
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | -        if (!$user instanceof PasswordAwareInterface) { | |
| 59 | +        if (!$user instanceof PasswordAwareInterface){ | |
| 60 | 60 |              throw new LogicException("User must be instance of PasswordAwareInterface"); | 
| 61 | 61 | } | 
| 62 | 62 | |
| 63 | -        if (!$this->hasher->hashEquals($password, $user->getPasswordHash())) { | |
| 63 | +        if (!$this->hasher->hashEquals($password, $user->getPasswordHash())){ | |
| 64 | 64 |              throw new CredentialsException("Unable to authorize, invalid password"); | 
| 65 | 65 | } | 
| 66 | 66 | |
| @@ -52,15 +52,18 @@ | ||
| 52 | 52 | public function getUser(string $username, string $password): PasswordAwareInterface | 
| 53 | 53 |      { | 
| 54 | 54 | $user = $this->source->findByUsername($username); | 
| 55 | -        if (empty($user)) { | |
| 55 | + if (empty($user)) | |
| 56 | +        { | |
| 56 | 57 |              throw new CredentialsException("Unable to authorize, no such user"); | 
| 57 | 58 | } | 
| 58 | 59 | |
| 59 | -        if (!$user instanceof PasswordAwareInterface) { | |
| 60 | + if (!$user instanceof PasswordAwareInterface) | |
| 61 | +        { | |
| 60 | 62 |              throw new LogicException("User must be instance of PasswordAwareInterface"); | 
| 61 | 63 | } | 
| 62 | 64 | |
| 63 | -        if (!$this->hasher->hashEquals($password, $user->getPasswordHash())) { | |
| 65 | + if (!$this->hasher->hashEquals($password, $user->getPasswordHash())) | |
| 66 | +        { | |
| 64 | 67 |              throw new CredentialsException("Unable to authorize, invalid password"); | 
| 65 | 68 | } | 
| 66 | 69 | |