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.

OrderBy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
A modify() 0 7 1
1
<?php
2
3
namespace Rb\Specification\Doctrine\Query;
4
5
use Doctrine\ORM\QueryBuilder;
6
use Rb\Specification\Doctrine\AbstractSpecification;
7
use Rb\Specification\Doctrine\Exception\InvalidArgumentException;
8
9
/**
10
 * Class OrderBy.
11
 */
12
class OrderBy extends AbstractSpecification
13
{
14
    const ASC  = 'ASC';
15
    const DESC = 'DESC';
16
17
    /**
18
     * @var string
19
     */
20
    protected $order;
21
22
    private static $validOrder = [self::ASC, self::DESC];
23
24
    /**
25
     * @param string      $field
26
     * @param string      $order
27
     * @param string|null $dqlAlias
28
     *
29
     * @throws InvalidArgumentException
30
     */
31
    public function __construct($field, $order = null, $dqlAlias = null)
32
    {
33
        $order = ! $order ? self::ASC : strtoupper($order);
34
35
        if (! in_array($order, self::$validOrder, true)) {
36
            throw new InvalidArgumentException();
37
        }
38
39
        $this->order = $order;
40
41
        parent::__construct($field, $dqlAlias);
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function modify(QueryBuilder $queryBuilder, $dqlAlias)
48
    {
49
        $queryBuilder->addOrderBy(
50
            $this->createPropertyWithAlias($dqlAlias),
51
            $this->order
52
        );
53
    }
54
}
55