Passed
Pull Request — master (#3233)
by Sergey
12:33
created

View::visit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

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