ntentan /
yentu
| 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
Bug
introduced
by
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
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
Loading history...
|
|||||||
| 43 | } |
||||||
| 44 | return $this; |
||||||
| 45 | } |
||||||
| 46 | |||||||
| 47 | public function view($name) |
||||||
| 48 | { |
||||||
| 49 | DatabaseItem::purge(); |
||||||
|
0 ignored issues
–
show
The method
purge() does not exist on yentu\database\DatabaseItem. Maybe you want to declare this class abstract?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 50 | return $this->create('view', $name, $this->schema); |
||||||
|
0 ignored issues
–
show
The method
create() does not exist on yentu\database\View. 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
Loading history...
|
|||||||
| 51 | } |
||||||
| 52 | |||||||
| 53 | public function table($name) |
||||||
| 54 | { |
||||||
| 55 | DatabaseItem::purge(); |
||||||
| 56 | return $this->create('table', $name, $this->schema); |
||||||
| 57 | } |
||||||
| 58 | |||||||
| 59 | #[\Override] |
||||||
| 60 | public function buildDescription() { |
||||||
| 61 | return array( |
||||||
| 62 | 'name' => $this->name, |
||||||
| 63 | 'schema' => $this->schema->getName(), |
||||||
| 64 | 'definition' => $this->definition |
||||||
| 65 | ); |
||||||
| 66 | } |
||||||
| 67 | } |
||||||
| 68 |