| Conditions | 1 |
| Paths | 1 |
| Total Lines | 89 |
| Code Lines | 68 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 50 | public function __construct(EventStoreInterface $eventStore, RecordsMessages $eventRecorder, string $lifetime) |
||
| 51 | { |
||
| 52 | $this->eventStore = $eventStore; |
||
| 53 | $this->eventRecorder = $eventRecorder; |
||
| 54 | $this->lifetime = $lifetime; |
||
| 55 | $this->createAndSaveAuthCode( |
||
| 56 | AuthCodeId::create('VALID_AUTH_CODE'), |
||
| 57 | ClientId::create('client1'), |
||
| 58 | UserAccountId::create('john.1'), |
||
| 59 | [], |
||
| 60 | 'https://www.example.com/callback', |
||
| 61 | new \DateTimeImmutable('now +1 day'), |
||
| 62 | DataBag::createFromArray([]), |
||
| 63 | DataBag::createFromArray([]), |
||
| 64 | ['openid', 'email', 'phone', 'address'], |
||
| 65 | false |
||
| 66 | ); |
||
| 67 | |||
| 68 | $this->createAndSaveAuthCode( |
||
| 69 | AuthCodeId::create('EXPIRED_AUTH_CODE'), |
||
| 70 | ClientId::create('client1'), |
||
| 71 | UserAccountId::create('john.1'), |
||
| 72 | [], |
||
| 73 | 'https://www.example.com/callback', |
||
| 74 | new \DateTimeImmutable('now -1 day'), |
||
| 75 | DataBag::createFromArray([]), |
||
| 76 | DataBag::createFromArray([]), |
||
| 77 | ['openid', 'email', 'phone', 'address'], |
||
| 78 | false |
||
| 79 | ); |
||
| 80 | |||
| 81 | $this->createRevokedAndSaveAuthCode( |
||
| 82 | AuthCodeId::create('REVOKED_AUTH_CODE'), |
||
| 83 | ClientId::create('client1'), |
||
| 84 | UserAccountId::create('john.1'), |
||
| 85 | [], |
||
| 86 | 'https://www.example.com/callback', |
||
| 87 | new \DateTimeImmutable('now +1 day'), |
||
| 88 | DataBag::createFromArray([]), |
||
| 89 | DataBag::createFromArray([]), |
||
| 90 | ['openid', 'email', 'phone', 'address'], |
||
| 91 | false |
||
| 92 | ); |
||
| 93 | |||
| 94 | $this->createUsedAndSaveAuthCode( |
||
| 95 | AuthCodeId::create('USED_AUTH_CODE'), |
||
| 96 | ClientId::create('client1'), |
||
| 97 | UserAccountId::create('john.1'), |
||
| 98 | [], |
||
| 99 | 'https://www.example.com/callback', |
||
| 100 | new \DateTimeImmutable('now +1 day'), |
||
| 101 | DataBag::createFromArray([]), |
||
| 102 | DataBag::createFromArray([]), |
||
| 103 | ['openid', 'email', 'phone', 'address'], |
||
| 104 | false |
||
| 105 | ); |
||
| 106 | |||
| 107 | $this->createAndSaveAuthCode( |
||
| 108 | AuthCodeId::create('AUTH_CODE_WITH_CODE_VERIFIER_PLAIN'), |
||
| 109 | ClientId::create('client1'), |
||
| 110 | UserAccountId::create('john.1'), |
||
| 111 | [ |
||
| 112 | 'code_challenge' => 'E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM', |
||
| 113 | 'code_challenge_method' => 'plain', |
||
| 114 | ], |
||
| 115 | 'https://www.example.com/callback', |
||
| 116 | new \DateTimeImmutable('now +1 day'), |
||
| 117 | DataBag::createFromArray([]), |
||
| 118 | DataBag::createFromArray([]), |
||
| 119 | ['openid', 'email', 'phone', 'address'], |
||
| 120 | false |
||
| 121 | ); |
||
| 122 | |||
| 123 | $this->createAndSaveAuthCode( |
||
| 124 | AuthCodeId::create('AUTH_CODE_WITH_CODE_VERIFIER_S256'), |
||
| 125 | ClientId::create('client1'), |
||
| 126 | UserAccountId::create('john.1'), |
||
| 127 | [ |
||
| 128 | 'code_challenge' => 'DSmbHrVIcI0EU05-BQxCe1bt-hXRNjejSEvdYbq_g4Q', |
||
| 129 | 'code_challenge_method' => 'S256', |
||
| 130 | ], |
||
| 131 | 'https://www.example.com/callback', |
||
| 132 | new \DateTimeImmutable('now +1 day'), |
||
| 133 | DataBag::createFromArray([]), |
||
| 134 | DataBag::createFromArray([]), |
||
| 135 | ['openid', 'email', 'phone', 'address'], |
||
| 136 | false |
||
| 137 | ); |
||
| 138 | } |
||
| 139 | |||
| 310 |