Conditions | 5 |
Paths | 3 |
Total Lines | 58 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 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 |
||
81 | public function findByToken($refreshTokenId) |
||
82 | { |
||
83 | $qb = $this->dbalConnection->createQueryBuilder(); |
||
84 | $stmt = $qb->select('*, r.expires_at AS refresh_token_expires_at') |
||
85 | ->from($this->tableConfiguration->getRefreshTokenTableName(), 'r') |
||
86 | ->innerJoin( |
||
87 | 'r', |
||
88 | $this->tableConfiguration->getAccessTokenTableName(), |
||
89 | 'a', |
||
90 | 'a.access_token = r.associated_access_token' |
||
91 | ) |
||
92 | ->where( |
||
93 | $qb->expr()->like('refresh_token', ':refreshToken') |
||
94 | ) |
||
95 | ->setMaxResults(1) |
||
96 | ->setParameter('refreshToken', $refreshTokenId) |
||
97 | ->execute() |
||
98 | ; |
||
99 | |||
100 | $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); |
||
101 | |||
102 | if (1 !== count($rows)) { |
||
103 | |||
104 | throw new RefreshTokenNotFound($refreshTokenId); |
||
105 | } |
||
106 | |||
107 | $revokedAt = (null !== $rows[0]['revoked_at']) |
||
108 | ? \DateTimeImmutable::createFromFormat( |
||
109 | 'Y-m-d H:i:s', |
||
110 | $rows[0]['revoked_at'], |
||
111 | new \DateTimeZone('UTC') |
||
112 | ) |
||
113 | : null |
||
114 | ; |
||
115 | |||
116 | return new RefreshToken( |
||
117 | $rows[0]['refresh_token'], |
||
118 | new AccessToken( |
||
119 | $rows[0]['access_token'], |
||
120 | \DateTimeImmutable::createFromFormat( |
||
121 | 'Y-m-d H:i:s', |
||
122 | $rows[0]['expires_at'], |
||
123 | new \DateTimeZone('UTC') |
||
124 | ), |
||
125 | $rows[0]['client_id'], |
||
126 | ($rows[0]['resource_owner_id'] && $rows[0]['resource_owner_type']) |
||
127 | ? new ResourceOwner($rows[0]['resource_owner_id'], $rows[0]['resource_owner_type']) |
||
128 | : null, |
||
129 | explode(',', $rows[0]['scopes']) |
||
130 | ), |
||
131 | \DateTimeImmutable::createFromFormat( |
||
132 | 'Y-m-d H:i:s', |
||
133 | $rows[0]['refresh_token_expires_at'], |
||
134 | new \DateTimeZone('UTC') |
||
135 | ), |
||
136 | $revokedAt |
||
137 | ); |
||
138 | } |
||
139 | } |
||
140 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.