ValidEnumElementName   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zlikavac32\SymfonyEnum\Validator\Constraints;
6
7
/**
8
 * @Annotation
9
 * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
10
 */
11
class ValidEnumElementName extends AbstractEnumConstraint
12
{
13
    public function __construct($options = null)
14
    {
15
        parent::__construct(
16
            function (): array {
17
                $choices = [];
18
19
                foreach ($this->enumClass::values() as $element) {
0 ignored issues
show
Bug introduced by
The method values() does not exist on null. ( Ignorable by Annotation )

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

19
                foreach ($this->enumClass::/** @scrutinizer ignore-call */ values() as $element) {

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...
20
                    $name = $element->name();
21
                    $choices[] = $name;
22
                }
23
24
                return $choices;
25
            },
26
            $options
27
        );
28
    }
29
}
30