Conditions | 3 |
Paths | 4 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
31 | public function archive($purpose = null, DateTime $before = null) |
||
32 | { |
||
33 | if (null !== $before) { |
||
34 | @trigger_error( |
||
|
|||
35 | 'The "before" argument of the "'.__METHOD__ |
||
36 | .'" method is deprecated since version 2.2 and will be removed in 3.0.', |
||
37 | E_USER_DEPRECATED |
||
38 | ); |
||
39 | } |
||
40 | |||
41 | $builder = $this->tokenRepository->createQueryBuilder('token') |
||
42 | ->delete($this->tokenRepository->getClassName(), 'token'); |
||
43 | |||
44 | $builder |
||
45 | ->where($builder->expr()->lt('token.keepUntil', ':now')) |
||
46 | ->setParameter('now', new DateTime()) |
||
47 | ; |
||
48 | |||
49 | if ($purpose) { |
||
50 | $builder |
||
51 | ->andWhere($builder->expr()->eq('token.purpose', ':purpose')) |
||
52 | ->setParameter('purpose', $purpose) |
||
53 | ; |
||
54 | } |
||
55 | |||
56 | return intval($builder->getQuery()->execute()); |
||
57 | } |
||
58 | } |
||
59 |
If you suppress an error, we recommend checking for the error condition explicitly: