Failed Conditions
Push — master ( 2f2402...0ef5da )
by Adrien
13:58
created

EnumAutoMigrator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 7
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A postGenerateSchema() 0 8 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Service;
6
7
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
8
use Ecodev\Felix\DBAL\Types\EnumType;
9
10
/**
11
 * When we update our enum values in PHP (native or non-native), a DB migration will be created automatically.
12
 */
13
class EnumAutoMigrator
14
{
15
    public function postGenerateSchema(GenerateSchemaEventArgs $eventArgs): void
16
    {
17
        foreach ($eventArgs->getSchema()->getTables() as $table) {
18
            foreach ($table->getColumns() as $column) {
19
                $type = $column->getType();
20
                if ($type instanceof EnumType) {
21
                    $hash = md5($type->getQuotedPossibleValues());
0 ignored issues
show
Bug introduced by
The method getQuotedPossibleValues() does not exist on Ecodev\Felix\DBAL\Types\EnumType. ( Ignorable by Annotation )

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

21
                    $hash = md5($type->/** @scrutinizer ignore-call */ getQuotedPossibleValues());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
22
                    $column->setComment("(FelixEnum:$hash)");
23
                }
24
            }
25
        }
26
    }
27
}
28