ModelClassValidator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 10 3
1
<?php
2
3
namespace Admingenerator\GeneratorBundle\Validator;
4
5
use Admingenerator\GeneratorBundle\Generator\Generator;
6
use Admingenerator\GeneratorBundle\Exception\ModelClassNotFoundException;
7
8
class ModelClassValidator extends BaseValidator implements ValidatorInterface
9
{
10
    public function validate(Generator $generator)
11
    {
12
        if (!$model = $this->getFromYaml($generator, 'params.model')) {
13
            throw new ModelClassNotFoundException(sprintf('You should define params.model option in %s', $generator->getGeneratorYml()));
0 ignored issues
show
Documentation introduced by
sprintf('You should defi...tor->getGeneratorYml()) is of type string, but the function expects a array<integer,object<Sym...r\ConstraintViolation>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
14
        }
15
16
        if (!class_exists($model)) {
17
            throw new ModelClassNotFoundException(sprintf('Unable to find class %s for %s', $model, $generator->getGeneratorYml()));
0 ignored issues
show
Documentation introduced by
sprintf('Unable to find ...tor->getGeneratorYml()) is of type string, but the function expects a array<integer,object<Sym...r\ConstraintViolation>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
18
        }
19
    }
20
}
21