RelativeClause   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 59
ccs 0
cts 13
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __toString() 0 4 1
A getRelatedTable() 0 4 1
A getClause() 0 4 1
A getDirective() 0 4 1
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
}