| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public function archive(string $purpose = null): int |
||
| 32 | { |
||
| 33 | $builder = $this->tokenRepository->createQueryBuilder('token') |
||
| 34 | ->delete($this->tokenRepository->getClassName(), 'token'); |
||
| 35 | |||
| 36 | $builder |
||
| 37 | ->where($builder->expr()->lt('token.keepUntil', ':now')) |
||
| 38 | ->setParameter('now', new DateTime()) |
||
| 39 | ; |
||
| 40 | |||
| 41 | if ($purpose) { |
||
|
|
|||
| 42 | $builder |
||
| 43 | ->andWhere($builder->expr()->eq('token.purpose', ':purpose')) |
||
| 44 | ->setParameter('purpose', $purpose) |
||
| 45 | ; |
||
| 46 | } |
||
| 47 | |||
| 48 | return intval($builder->getQuery()->execute()); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: