Completed
Pull Request — master (#3233)
by Sergey
60:52
created

View   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 9
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isSameAs() 0 3 1
A getSql() 0 3 1
A visit() 0 7 2
1
<?php
2
3
namespace Doctrine\DBAL\Schema;
4
5
use Doctrine\DBAL\Schema\Visitor\ViewVisitor;
6
use Doctrine\DBAL\Schema\Visitor\Visitor;
7
8
/**
9
 * Representation of a Database View.
10
 */
11
class View extends AbstractAsset
12
{
13
    /** @var string */
14
    private $sql;
15
16
    public function __construct(string $name, string $sql)
17 25
    {
18
        $this->_setName($name);
19 25
        $this->sql = $sql;
20 25
    }
21 25
22
    public function getSql(): string
23
    {
24
        return $this->sql;
25
    }
26 25
27
    public function visit(Visitor $visitor): void
28 25
    {
29
        if (! ($visitor instanceof ViewVisitor)) {
30
            return;
31
        }
32
33
        $visitor->acceptView($this);
34
    }
35
36
    public function isSameAs(View $anotherView): bool
37
    {
38
        return $anotherView->getSql() === $this->getSql();
39
    }
40
}
41