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

View::isSameAs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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