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

View::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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