GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Between   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 55
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A modify() 0 14 1
A generateParameterName() 0 4 1
1
<?php
2
3
namespace Rb\Specification\Doctrine\Condition;
4
5
use Doctrine\ORM\QueryBuilder;
6
use Rb\Specification\Doctrine\AbstractSpecification;
7
8
class Between extends AbstractSpecification
9
{
10
    /**
11
     * @var mixed
12
     */
13
    protected $from;
14
15
    /**
16
     * @var mixed
17
     */
18
    protected $to;
19
20
    /**
21
     * @param string      $field
22
     * @param mixed       $from
23
     * @param mixed       $to
24
     * @param string|null $dqlAlias
25
     */
26
    public function __construct($field, $from, $to, $dqlAlias = null)
27
    {
28
        $this->from = $from;
29
        $this->to   = $to;
30
31
        parent::__construct($field, $dqlAlias);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function modify(QueryBuilder $queryBuilder, $dqlAlias)
38
    {
39
        $fromParam = $this->generateParameterName('from', $queryBuilder);
40
        $toParam   = $this->generateParameterName('to', $queryBuilder);
41
42
        $queryBuilder->setParameter($fromParam, $this->from);
43
        $queryBuilder->setParameter($toParam, $this->to);
44
45
        return (string) $queryBuilder->expr()->between(
46
            $this->createPropertyWithAlias($dqlAlias),
47
            sprintf(':%s', $fromParam),
48
            sprintf(':%s', $toParam)
49
        );
50
    }
51
52
    /**
53
     * @param string       $type
54
     * @param QueryBuilder $queryBuilder
55
     *
56
     * @return string
57
     */
58
    private function generateParameterName($type, QueryBuilder $queryBuilder)
59
    {
60
        return sprintf('%s_%d', $type, count($queryBuilder->getParameters()));
61
    }
62
}
63