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

View   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 8
dl 0
loc 38
rs 10
c 0
b 0
f 0
ccs 12
cts 12
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isSameAs() 0 3 1
A getSql() 0 3 1
A visit() 0 4 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