Passed
Pull Request — master (#220)
by Anton
07:03 queued 03:15
created
src/Session/SessionScope.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -123,9 +123,9 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -123,9 +123,12 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Cookies/CookieManager.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -169,9 +169,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Auth/Session/Token.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Auth/Cycle/Token.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Auth/AuthScope.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,9 +94,9 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,9 +94,12 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Security/GuardScope.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,8 +55,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Auth/Cycle/TokenRepository.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,25 +41,25 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function load(string $id): ?TokenInterface
43 43
     {
44
-        if (strpos($id, ':') === false) {
44
+        if (strpos($id, ':') === false){
45 45
             return null;
46 46
         }
47 47
 
48 48
         list($pk, $hash) = explode(':', $id, 2);
49 49
 
50
-        if (!is_numeric($id)) {
50
+        if (!is_numeric($id)){
51 51
             return null;
52 52
         }
53 53
 
54 54
         /** @var TokenInterface $token */
55 55
         $token = $this->findByPK((int)$pk);
56 56
 
57
-        if ($token === null || $token->getID() !== $id) {
57
+        if ($token === null || $token->getID() !== $id){
58 58
             // hijacked or deleted
59 59
             return null;
60 60
         }
61 61
 
62
-        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) {
62
+        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()){
63 63
             $this->delete($token);
64 64
             return null;
65 65
         }
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface
74 74
     {
75
-        try {
75
+        try{
76 76
             $token = new Token($this->randomHash(128), $payload, new \DateTimeImmutable(), $expiresAt);
77 77
 
78 78
             (new Transaction($this->orm))->persist($token)->run();
79 79
 
80 80
             return $token;
81
-        } catch (\Throwable $e) {
81
+        }catch (\Throwable $e){
82 82
             throw new TokenStorageException('Unable to create token', $e->getCode(), $e);
83 83
         }
84 84
     }
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function delete(TokenInterface $token): void
90 90
     {
91
-        try {
91
+        try{
92 92
             (new Transaction($this->orm))->delete($token)->run();
93
-        } catch (\Throwable $e) {
93
+        }catch (\Throwable $e){
94 94
             throw new TokenStorageException('Unable to delete token', $e->getCode(), $e);
95 95
         }
96 96
     }
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,25 +41,29 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function load(string $id): ?TokenInterface
43 43
     {
44
-        if (strpos($id, ':') === false) {
44
+        if (strpos($id, ':') === false)
45
+        {
45 46
             return null;
46 47
         }
47 48
 
48 49
         list($pk, $hash) = explode(':', $id, 2);
49 50
 
50
-        if (!is_numeric($id)) {
51
+        if (!is_numeric($id))
52
+        {
51 53
             return null;
52 54
         }
53 55
 
54 56
         /** @var TokenInterface $token */
55 57
         $token = $this->findByPK((int)$pk);
56 58
 
57
-        if ($token === null || $token->getID() !== $id) {
59
+        if ($token === null || $token->getID() !== $id)
60
+        {
58 61
             // hijacked or deleted
59 62
             return null;
60 63
         }
61 64
 
62
-        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) {
65
+        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime())
66
+        {
63 67
             $this->delete($token);
64 68
             return null;
65 69
         }
@@ -72,13 +76,16 @@  discard block
 block discarded – undo
72 76
      */
73 77
     public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface
74 78
     {
75
-        try {
79
+        try
80
+        {
76 81
             $token = new Token($this->randomHash(128), $payload, new \DateTimeImmutable(), $expiresAt);
77 82
 
78 83
             (new Transaction($this->orm))->persist($token)->run();
79 84
 
80 85
             return $token;
81
-        } catch (\Throwable $e) {
86
+        }
87
+        catch (\Throwable $e)
88
+        {
82 89
             throw new TokenStorageException('Unable to create token', $e->getCode(), $e);
83 90
         }
84 91
     }
@@ -88,9 +95,12 @@  discard block
 block discarded – undo
88 95
      */
89 96
     public function delete(TokenInterface $token): void
90 97
     {
91
-        try {
98
+        try
99
+        {
92 100
             (new Transaction($this->orm))->delete($token)->run();
93
-        } catch (\Throwable $e) {
101
+        }
102
+        catch (\Throwable $e)
103
+        {
94 104
             throw new TokenStorageException('Unable to delete token', $e->getCode(), $e);
95 105
         }
96 106
     }
Please login to merge, or discard this patch.
src/Auth/Config/AuthConfig.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
     public function getTransports(): array
41 41
     {
42 42
         $transports = [];
43
-        foreach ($this->config['transports'] as $transport) {
44
-            if (is_object($transport) && !$transport instanceof Autowire) {
43
+        foreach ($this->config['transports'] as $transport){
44
+            if (is_object($transport) && !$transport instanceof Autowire){
45 45
                 $transports[] = $transport;
46 46
                 continue;
47 47
             }
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
      */
61 61
     private function wire($item): Autowire
62 62
     {
63
-        if ($item instanceof Autowire) {
63
+        if ($item instanceof Autowire){
64 64
             return $item;
65 65
         }
66 66
 
67
-        if (is_string($item)) {
67
+        if (is_string($item)){
68 68
             return new Autowire($item);
69 69
         }
70 70
 
71
-        if (is_array($item) && isset($item['class'])) {
71
+        if (is_array($item) && isset($item['class'])){
72 72
             return new Autowire($item['class'], $item['options'] ?? []);
73 73
         }
74 74
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,8 +40,10 @@  discard block
 block discarded – undo
40 40
     public function getTransports(): array
41 41
     {
42 42
         $transports = [];
43
-        foreach ($this->config['transports'] as $transport) {
44
-            if (is_object($transport) && !$transport instanceof Autowire) {
43
+        foreach ($this->config['transports'] as $transport)
44
+        {
45
+            if (is_object($transport) && !$transport instanceof Autowire)
46
+            {
45 47
                 $transports[] = $transport;
46 48
                 continue;
47 49
             }
@@ -60,15 +62,18 @@  discard block
 block discarded – undo
60 62
      */
61 63
     private function wire($item): Autowire
62 64
     {
63
-        if ($item instanceof Autowire) {
65
+        if ($item instanceof Autowire)
66
+        {
64 67
             return $item;
65 68
         }
66 69
 
67
-        if (is_string($item)) {
70
+        if (is_string($item))
71
+        {
68 72
             return new Autowire($item);
69 73
         }
70 74
 
71
-        if (is_array($item) && isset($item['class'])) {
75
+        if (is_array($item) && isset($item['class']))
76
+        {
72 77
             return new Autowire($item['class'], $item['options'] ?? []);
73 78
         }
74 79
 
Please login to merge, or discard this patch.
src/Auth/Session/TokenStorage.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function load(string $id): ?TokenInterface
45 45
     {
46
-        try {
46
+        try{
47 47
             $tokenData = $this->getAuthSection()->get('token');
48 48
             $token = Token::unpack($tokenData);
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Braces   +19 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,18 +43,23 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function load(string $id): ?TokenInterface
45 45
     {
46
-        try {
46
+        try
47
+        {
47 48
             $tokenData = $this->getAuthSection()->get('token');
48 49
             $token = Token::unpack($tokenData);
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.