RelativeClause::getRelatedTable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * This file is part of UnderQuery package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\UnderQuery\Language\Expression;
13
14
use Phuria\UnderQuery\Table\TableInterface;
15
16
/**
17
 * @author Beniamin Jonatan Šimko <[email protected]>
18
 */
19
class RelativeClause
20
{
21
    const RELATIVE_DIRECTIVE = '@.';
22
    const SELF_DIRECTIVE = '@self.';
23
24
    /**
25
     * @var TableInterface
26
     */
27
    private $relatedTable;
28
29
    /**
30
     * @var string
31
     */
32
    private $clause;
33
34
    /**
35
     * @param TableInterface $relatedTo
36
     * @param string         $clause
37
     * @param string         $directive
38
     */
39
    public function __construct(TableInterface $relatedTo, $clause, $directive)
40
    {
41
        $this->relatedTable = $relatedTo;
42
        $this->clause = $clause;
43
        $this->directive = $directive;
0 ignored issues
show
Bug introduced by
The property directive does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function __toString()
50
    {
51
        return $this->relatedTable->getQueryBuilder()->toReference($this);
52
    }
53
54
    /**
55
     * @return TableInterface
56
     */
57
    public function getRelatedTable()
58
    {
59
        return $this->relatedTable;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getClause()
66
    {
67
        return $this->clause;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getDirective()
74
    {
75
        return $this->directive;
76
    }
77
}