Completed
Pull Request — master (#3233)
by Sergey
65:15
created

View::visit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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
    /**
17 25
     * @param string $name
18
     * @param string $sql
19 25
     */
20 25
    public function __construct($name, $sql)
21 25
    {
22
        $this->_setName($name);
23
        $this->sql = $sql;
24
    }
25
26 25
    /**
27
     * @return string
28 25
     */
29
    public function getSql()
30
    {
31
        return $this->sql;
32
    }
33
34
    /**
35
     * @return void
36
     */
37
    public function visit(Visitor $visitor)
38
    {
39
        if (! ($visitor instanceof ViewVisitor)) {
40
            return;
41
        }
42
43
        $visitor->acceptView($this);
44
    }
45
46
    public function isSameAs(View $anotherView)
47
    {
48
        return $anotherView->getSql() === $this->getSql();
49
    }
50
}
51