Completed
Push — master ( b7ef6a...58a002 )
by Kirill
03:12
created

Selection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 50
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A hasAlias() 0 4 1
A getAlias() 0 4 1
A getField() 0 4 1
1
<?php
2
/**
3
 * This file is part of Hydrogen package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace RDS\Hydrogen\Criteria;
11
12
use RDS\Hydrogen\Criteria\Common\Field;
13
use RDS\Hydrogen\Query;
14
15
/**
16
 * Class Selection
17
 */
18
class Selection extends Criterion
19
{
20
    /**
21
     * @var Field
22
     */
23
    private $field;
24
25
    /**
26
     * @var string|null
27
     */
28
    private $as;
29
30
    /**
31
     * Selection constructor.
32
     * @param Query $query
33
     * @param string $field
34
     * @param string|null $alias
35
     */
36 30
    public function __construct(Query $query, string $field, string $alias = null)
37
    {
38 30
        parent::__construct($query);
39
40 30
        $this->field = $this->field($field);
41 30
        $this->as = $alias;
42 30
    }
43
44
    /**
45
     * @return bool
46
     */
47 30
    public function hasAlias(): bool
48
    {
49 30
        return $this->as !== null;
50
    }
51
52
    /**
53
     * @return null|string
54
     */
55
    public function getAlias(): ?string
56
    {
57
        return $this->as;
58
    }
59
60
    /**
61
     * @return Field
62
     */
63 30
    public function getField(): Field
64
    {
65 30
        return $this->field;
66
    }
67
}
68