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

View::isSameAs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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