Passed
Push — master ( 1791d6...48fae4 )
by Anton
01:59
created

src/Generator/CleanTables.php (1 issue)

Labels
Severity
1
<?php declare(strict_types=1);
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
9
namespace Cycle\Schema\Generator;
10
11
use Cycle\Schema\GeneratorInterface;
12
use Cycle\Schema\Registry;
13
14
/**
15
 * Declare table dropped (initiate diff calculation).
16
 */
17
final class CleanTables implements GeneratorInterface
18
{
19
    /**
20
     * @param Registry $registry
21
     * @return Registry
22
     */
23
    public function run(Registry $registry): Registry
24
    {
25
        foreach ($registry as $entity) {
26
            if (!$registry->hasTable($entity)) {
27
                continue;
28
            }
29
30
            if (!$entity->getOptions()->has(RenderTables::READONLY)) {
0 ignored issues
show
The constant Cycle\Schema\Generator\RenderTables::READONLY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
31
                $registry->getTableSchema($entity)->declareDropped();
32
            }
33
        }
34
35
        return $registry;
36
    }
37
}