edmondscommerce /
doctrine-static-meta
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Process; |
||
| 6 | |||
| 7 | use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File; |
||
| 8 | use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\IdFieldTrait; |
||
| 9 | use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\IntegerIdFieldTrait; |
||
|
0 ignored issues
–
show
|
|||
| 10 | use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\NonBinaryUuidFieldTrait; |
||
| 11 | use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\UuidFieldTrait; |
||
| 12 | use LogicException; |
||
| 13 | use RuntimeException; |
||
| 14 | |||
| 15 | class ReplaceEntityIdFieldProcess implements ProcessInterface |
||
| 16 | { |
||
| 17 | |||
| 18 | public const FIND_USE_STATEMENT = 'use DSM\Fields\Traits\PrimaryKey\IdFieldTrait;'; |
||
| 19 | /** |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | private $idTraitFqn; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Specify the IdFieldTrait fully qualified name, eg UuidFieldTrait::class |
||
| 26 | * |
||
| 27 | * @param string $idTraitFqn |
||
| 28 | * |
||
| 29 | * @return ReplaceEntityIdFieldProcess |
||
| 30 | */ |
||
| 31 | 6 | public function setIdTraitFqn(string $idTraitFqn): self |
|
| 32 | { |
||
| 33 | 6 | $this->idTraitFqn = $idTraitFqn; |
|
| 34 | |||
| 35 | 6 | return $this; |
|
| 36 | } |
||
| 37 | |||
| 38 | 6 | public function run(File\FindReplace $findReplace): void |
|
| 39 | { |
||
| 40 | 6 | if (null === $this->idTraitFqn) { |
|
| 41 | throw new RuntimeException('you must set the IdTraitFqn'); |
||
| 42 | } |
||
| 43 | 6 | $findReplace->findReplace(self::FIND_USE_STATEMENT, $this->getUseStatement()); |
|
| 44 | 6 | } |
|
| 45 | |||
| 46 | /** |
||
| 47 | * Get the use statement to replace it with |
||
| 48 | * |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | 6 | private function getUseStatement(): string |
|
| 52 | { |
||
| 53 | 6 | switch ($this->idTraitFqn) { |
|
| 54 | case IdFieldTrait::class: |
||
| 55 | 2 | $useStatement = 'use DSM\Fields\Traits\PrimaryKey\IdFieldTrait;'; |
|
| 56 | 2 | break; |
|
| 57 | case NonBinaryUuidFieldTrait::class: |
||
| 58 | 2 | $useStatement = 'use DSM\Fields\Traits\PrimaryKey\NonBinaryUuidFieldTrait;'; |
|
| 59 | 2 | break; |
|
| 60 | case UuidFieldTrait::class: |
||
| 61 | 2 | $useStatement = 'use DSM\Fields\Traits\PrimaryKey\UuidFieldTrait;'; |
|
| 62 | 2 | break; |
|
| 63 | default: |
||
| 64 | throw new LogicException('Unknown trait selected ' . $this->idTraitFqn); |
||
| 65 | } |
||
| 66 | |||
| 67 | 6 | return $useStatement; |
|
| 68 | } |
||
| 69 | } |
||
| 70 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths