| Conditions | 1 |
| Paths | 1 |
| Total Lines | 55 |
| 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 |
||
| 45 | throw new \InvalidArgumentException('Unsupported authorization code class'); |
||
| 46 | } |
||
| 47 | $this->entityManager->persist($accessToken); |
||
| 48 | $this->entityManager->flush(); |
||
| 49 | } |
||
| 50 | |||
| 51 | public function create(ClientId $clientId, UserAccountId $userAccountId, array $queryParameters, string $redirectUri, \DateTimeImmutable $expiresAt, DataBag $parameter, DataBag $metadata, ?ResourceServerId $resourceServerId): CoreAuthorizationCode |
||
| 52 | { |
||
| 53 | return new AuthorizationCode( |
||
| 54 | new AuthorizationCodeId(\bin2hex(\random_bytes(32))), |
||
| 55 | $clientId, |
||
| 56 | $userAccountId, |
||
| 57 | $queryParameters, |
||
| 58 | $redirectUri, |
||
| 59 | $expiresAt, |
||
| 60 | $parameter, |
||
| 61 | $metadata, |
||
| 62 | $resourceServerId |
||
| 63 | ); |
||
| 64 | } |
||
| 65 | } |
||
| 66 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.