Issues (88)

src/database/View.php (3 issues)

Labels
Severity
1
<?php
2
namespace yentu\database;
3
4
use yentu\database\DatabaseItem;
5
6
7
class View extends DatabaseItem implements Changeable, Initializable
8
{
9
    private $name;
10
    private $schema;
11
    
12
    public $definition;
13
    
14
    public function __construct($name, $schema) 
15
    {
16
        $this->name = $name;
17
        $this->schema = $schema;
18
    }
19
    
20
    #[\Override]
21
    public function initialize(): void
22
    {
23
        $this->definition = $this->getChangeLogger()->doesViewExist($this->buildDescription());
0 ignored issues
show
The method doesViewExist() does not exist on yentu\ChangeLogger. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        $this->definition = $this->getChangeLogger()->/** @scrutinizer ignore-call */ doesViewExist($this->buildDescription());
Loading history...
24
        if($this->definition === false)
25
        {
26
            $this->new = true;
27
        }        
28
    }
29
    
30
    public function drop()
31
    {
32
        $this->getChangeLogger()->dropView($this->buildDescription());
0 ignored issues
show
The method dropView() does not exist on yentu\ChangeLogger. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $this->getChangeLogger()->/** @scrutinizer ignore-call */ dropView($this->buildDescription());
Loading history...
33
        return $this;
34
    }
35
    
36
    public function definition($definition)
37
    {
38
        $this->addChange('definition', 'definition', $definition);
39
        
40
        if($this->isNew())
41
        {
42
            $this->getChangeLogger()->addView($this->buildDescription());
0 ignored issues
show
The method addView() does not exist on yentu\ChangeLogger. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
            $this->getChangeLogger()->/** @scrutinizer ignore-call */ addView($this->buildDescription());
Loading history...
43
        }
44
        return $this;
45
    }
46
    
47
    public function view($name)
48
    {
49
        return $this->factory->create(ItemType::View, $name, $this->schema);
50
    }
51
    
52
    public function table($name)
53
    {
54
        return $this->factory->create(ItemType::Table, $name, $this->schema);
55
    }
56
    
57
    #[\Override]
58
    public function buildDescription() {
59
        return array(
60
            'name' => $this->name,
61
            'schema' => $this->schema->getName(),
62
            'definition' => $this->definition
63
        );
64
    }    
65
}
66