Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Code Lines | 46 |
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 |
||
51 | private function initAuthorizationCodes() |
||
52 | { |
||
53 | $authorizationCode = AuthorizationCode::createEmpty(); |
||
54 | $authorizationCode = $authorizationCode->create( |
||
55 | AuthorizationCodeId::create('VALID_AUTHORIZATION_CODE'), |
||
56 | ClientId::create('CLIENT_ID_3'), |
||
57 | UserAccountId::create('john.1'), |
||
58 | [], |
||
59 | 'http://localhost/callback', |
||
60 | new \DateTimeImmutable('now +1 day'), |
||
61 | DataBag::create([]), |
||
62 | DataBag::create([]), |
||
63 | null |
||
64 | ); |
||
65 | $this->save($authorizationCode); |
||
66 | |||
67 | $authorizationCode = AuthorizationCode::createEmpty(); |
||
68 | $authorizationCode = $authorizationCode->create( |
||
69 | AuthorizationCodeId::create('VALID_AUTHORIZATION_CODE_FOR_CONFIDENTIAL_CLIENT'), |
||
70 | ClientId::create('CLIENT_ID_5'), |
||
71 | UserAccountId::create('john.1'), |
||
72 | [], |
||
73 | 'http://localhost/callback', |
||
74 | new \DateTimeImmutable('now +1 day'), |
||
75 | DataBag::create([]), |
||
76 | DataBag::create([]), |
||
77 | null |
||
78 | ); |
||
79 | $this->save($authorizationCode); |
||
80 | |||
81 | $authorizationCode = AuthorizationCode::createEmpty(); |
||
82 | $authorizationCode = $authorizationCode->create( |
||
83 | AuthorizationCodeId::create('REVOKED_AUTHORIZATION_CODE'), |
||
84 | ClientId::create('CLIENT_ID_3'), |
||
85 | UserAccountId::create('john.1'), |
||
86 | [], |
||
87 | 'http://localhost/callback', |
||
88 | new \DateTimeImmutable('now +1 day'), |
||
89 | DataBag::create([]), |
||
90 | DataBag::create([]), |
||
91 | null |
||
92 | ); |
||
93 | $authorizationCode = $authorizationCode->markAsRevoked(); |
||
94 | $this->save($authorizationCode); |
||
95 | |||
96 | $authorizationCode = AuthorizationCode::createEmpty(); |
||
97 | $authorizationCode = $authorizationCode->create( |
||
98 | AuthorizationCodeId::create('EXPIRED_AUTHORIZATION_CODE'), |
||
99 | ClientId::create('CLIENT_ID_3'), |
||
100 | UserAccountId::create('john.1'), |
||
101 | [], |
||
102 | 'http://localhost/callback', |
||
103 | new \DateTimeImmutable('now -1 day'), |
||
104 | DataBag::create([]), |
||
105 | DataBag::create([]), |
||
106 | null |
||
107 | ); |
||
108 | $this->save($authorizationCode); |
||
109 | } |
||
110 | } |
||
111 |