Passed
Push — master ( 9eff33...c2decf )
by Anthony
03:23
created

AccountTokenRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A findByExpiredToken() 0 12 1
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Repository;
4
5
use Doctrine\DBAL\Types\Type;
0 ignored issues
show
Bug introduced by
The type Doctrine\DBAL\Types\Type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Doctrine\ORM\EntityRepository;
7
use Exception;
8
9
class AccountTokenRepository extends EntityRepository
10
{
11
    /**
12
     * method to find UserToken to archive
13
     * @param int $max_inactivation_days
14
     * @return mixed
15
     * @throws Exception
16
     */
17
    public function findByExpiredToken(int $max_inactivation_days)
18
    {
19
        $now = new \DateTime();
20
        $now->sub(new \DateInterval("P" . $max_inactivation_days . "D"));
21
22
        $query = $this->getEntityManager()->createQuery("SELECT u FROM App:AccountToken u WHERE
23
			u.endToken < :max_inactivation_days
24
		");
25
26
        $query->setParameter("max_inactivation_days", $now, Type::DATETIME);
27
28
        return $query->getResult();
29
    }
30
}
31