Test Failed
Push — develop ( a061b1...df8064 )
by nguereza
02:52
created
src/Migration/MigrationRepository.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,14 +55,12 @@
 block discarded – undo
55 55
  * @package Platine\Framework\Migration
56 56
  * @extends Repository<MigrationEntity>
57 57
  */
58
-class MigrationRepository extends Repository
59
-{
58
+class MigrationRepository extends Repository {
60 59
     /**
61 60
      * Create new instance
62 61
      * @param EntityManager<MigrationEntity> $manager
63 62
      */
64
-    public function __construct(EntityManager $manager)
65
-    {
63
+    public function __construct(EntityManager $manager) {
66 64
         parent::__construct($manager, MigrationEntity::class);
67 65
     }
68 66
 }
Please login to merge, or discard this patch.
src/Security/JWT/Encoder/Base64UrlSafeEncoder.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,8 +53,7 @@
 block discarded – undo
53 53
  * @class Base64UrlSafeEncoder
54 54
  * @package Platine\Framework\Security\JWT\Encoder
55 55
  */
56
-class Base64UrlSafeEncoder implements EncoderInterface
57
-{
56
+class Base64UrlSafeEncoder implements EncoderInterface {
58 57
     /**
59 58
      * {@inheritdoc}
60 59
      */
Please login to merge, or discard this patch.
src/Security/JWT/EncoderInterface.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,8 +51,7 @@
 block discarded – undo
51 51
  * @class EncoderInterface
52 52
  * @package Platine\Framework\Security\JWT
53 53
  */
54
-interface EncoderInterface
55
-{
54
+interface EncoderInterface {
56 55
     /**
57 56
      * Encode the given data
58 57
      * @param string $data
Please login to merge, or discard this patch.
src/Security/JWT/JWT.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -146,8 +146,8 @@
 block discarded – undo
146 146
                     ));
147 147
                 } else {
148 148
                     $this->setHeaders($headers)
149
-                          ->setPayload($payload)
150
-                           ->setOriginalToken($token)
149
+                            ->setPayload($payload)
150
+                            ->setOriginalToken($token)
151 151
                             ->setEncodedSignature($parts[2]);
152 152
 
153 153
                     if (!$this->verify()) {
Please login to merge, or discard this patch.
Braces   +17 added lines, -18 removed lines patch added patch discarded remove patch
@@ -57,8 +57,7 @@  discard block
 block discarded – undo
57 57
  * @class JWT
58 58
  * @package Platine\Framework\Security\JWT
59 59
  */
60
-class JWT
61
-{
60
+class JWT {
62 61
     /**
63 62
      * The payload
64 63
      * @var array<string, mixed>
@@ -121,7 +120,7 @@  discard block
 block discarded – undo
121 120
     public function __construct(
122 121
         SignerInterface $signer,
123 122
         ?EncoderInterface $encoder = null
124
-    ) {
123
+    ) {
125 124
         $this->encoder = $encoder ?? new Base64UrlSafeEncoder();
126 125
         $this->signer = $signer;
127 126
     }
@@ -134,30 +133,30 @@  discard block
 block discarded – undo
134 133
     public function decode(string $token): self
135 134
     {
136 135
         $parts = explode('.', $token);
137
-        if (count($parts) === 3) {
136
+        if (count($parts) === 3) {
138 137
             $headers = json_decode($this->encoder->decode($parts[0]), true);
139 138
             $payload = json_decode($this->encoder->decode($parts[1]), true);
140
-            if (is_array($headers) && is_array($payload)) {
139
+            if (is_array($headers) && is_array($payload)) {
141 140
                 $algo = $headers['alg'] ?? '';
142
-                if (empty($algo) || $algo !== $this->signer->getTokenAlgoName()) {
141
+                if (empty($algo) || $algo !== $this->signer->getTokenAlgoName()) {
143 142
                     throw new InvalidTokenException(sprintf(
144 143
                         'The token [%s] cannot be validated, missing or invalid algorithm',
145 144
                         $token
146 145
                     ));
147
-                } else {
146
+                } else {
148 147
                     $this->setHeaders($headers)
149 148
                           ->setPayload($payload)
150 149
                            ->setOriginalToken($token)
151 150
                             ->setEncodedSignature($parts[2]);
152 151
 
153
-                    if (!$this->verify()) {
152
+                    if (!$this->verify()) {
154 153
                         throw new InvalidTokenException(sprintf(
155 154
                             'The token [%s] cannot be verified because it is invalid',
156 155
                             $token
157 156
                         ));
158 157
                     }
159 158
 
160
-                    if ($this->isExpired()) {
159
+                    if ($this->isExpired()) {
161 160
                         throw new TokenExpiredException(sprintf(
162 161
                             'The token [%s] is already expired',
163 162
                             $token
@@ -182,7 +181,7 @@  discard block
 block discarded – undo
182 181
      */
183 182
     public function verify(): bool
184 183
     {
185
-        if (empty($this->secret) || empty($this->headers['alg'])) {
184
+        if (empty($this->secret) || empty($this->headers['alg'])) {
186 185
             return false;
187 186
         }
188 187
 
@@ -201,7 +200,7 @@  discard block
 block discarded – undo
201 200
     {
202 201
         $parts = explode('.', $this->originalToken);
203 202
 
204
-        if (count($parts) >= 2) {
203
+        if (count($parts) >= 2) {
205 204
             return sprintf('%s.%s', $parts[0], $parts[1]);
206 205
         }
207 206
 
@@ -230,7 +229,7 @@  discard block
 block discarded – undo
230 229
      */
231 230
     public function getSignature(): string
232 231
     {
233
-        if ($this->signed) {
232
+        if ($this->signed) {
234 233
             return $this->signature;
235 234
         }
236 235
 
@@ -297,15 +296,15 @@  discard block
 block discarded – undo
297 296
      */
298 297
     public function isExpired(): bool
299 298
     {
300
-        if (isset($this->payload['exp'])) {
299
+        if (isset($this->payload['exp'])) {
301 300
             $exp = $this->payload['exp'];
302 301
             $now = new DateTime('now');
303 302
 
304
-            if (is_int($exp)) {
303
+            if (is_int($exp)) {
305 304
                 return ($now->getTimestamp() - $exp) > 0;
306 305
             }
307 306
 
308
-            if (is_numeric($exp)) {
307
+            if (is_numeric($exp)) {
309 308
                 return ((float) $now->format('U') - $exp) > 0;
310 309
             }
311 310
         }
@@ -461,15 +460,15 @@  discard block
 block discarded – undo
461 460
      */
462 461
     protected function setDefaults(): void
463 462
     {
464
-        if (!isset($this->headers['typ'])) {
463
+        if (!isset($this->headers['typ'])) {
465 464
             $this->headers['typ'] = 'JWT';
466 465
         }
467 466
 
468
-        if (!isset($this->headers['alg'])) {
467
+        if (!isset($this->headers['alg'])) {
469 468
             $this->headers['alg'] = $this->signer->getTokenAlgoName();
470 469
         }
471 470
 
472
-        if (!isset($this->payload['iat'])) {
471
+        if (!isset($this->payload['iat'])) {
473 472
             $this->payload['iat'] = time();
474 473
         }
475 474
     }
Please login to merge, or discard this patch.
src/Security/JWT/Exception/InvalidAlgorithmException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,6 +37,5 @@
 block discarded – undo
37 37
  * @class InvalidAlgorithmException
38 38
  * @package Platine\Framework\Security\JWT\Exception
39 39
  */
40
-class InvalidAlgorithmException extends JWTException
41
-{
40
+class InvalidAlgorithmException extends JWTException {
42 41
 }
Please login to merge, or discard this patch.
src/Security/JWT/Exception/InvalidTokenException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,6 +37,5 @@
 block discarded – undo
37 37
  * @class InvalidTokenException
38 38
  * @package Platine\Framework\Security\JWT\Exception
39 39
  */
40
-class InvalidTokenException extends JWTException
41
-{
40
+class InvalidTokenException extends JWTException {
42 41
 }
Please login to merge, or discard this patch.
src/Security/JWT/Exception/JWTException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,6 +39,5 @@
 block discarded – undo
39 39
  * @class JWTException
40 40
  * @package Platine\Framework\Security\JWT\Exception
41 41
  */
42
-class JWTException extends Exception
43
-{
42
+class JWTException extends Exception {
44 43
 }
Please login to merge, or discard this patch.
src/Security/JWT/Exception/TokenExpiredException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,6 +37,5 @@
 block discarded – undo
37 37
  * @class TokenExpiredException
38 38
  * @package Platine\Framework\Security\JWT\Exception
39 39
  */
40
-class TokenExpiredException extends JWTException
41
-{
40
+class TokenExpiredException extends JWTException {
42 41
 }
Please login to merge, or discard this patch.
src/Security/JWT/Signer/HMAC.php 1 patch
Braces   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
56 56
  * @package Platine\Framework\Security\JWT\Signer
57 57
  * @template T
58 58
  */
59
-class HMAC implements SignerInterface
60
-{
59
+class HMAC implements SignerInterface {
61 60
     /**
62 61
      * The configuration instance
63 62
      * @var Config<T>
@@ -74,11 +73,10 @@  discard block
 block discarded – undo
74 73
      * Create new instance
75 74
      * @param Config<T> $config
76 75
      */
77
-    public function __construct(Config $config)
78
-    {
76
+    public function __construct(Config $config) {
79 77
         $this->config = $config;
80 78
         $algo = $config->get('api.sign.hmac.signature_algo', '');
81
-        if (!in_array($algo, hash_hmac_algos())) {
79
+        if (!in_array($algo, hash_hmac_algos())) {
82 80
             throw new InvalidAlgorithmException(sprintf(
83 81
                 'Invalid HMAC algorithm [%s]',
84 82
                 $algo
Please login to merge, or discard this patch.