Ip   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 52.94%

Importance

Changes 0
Metric Value
wmc 14
eloc 18
dl 0
loc 26
ccs 9
cts 17
cp 0.5294
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C generateForProperty() 0 24 14
1
<?php
2
3
namespace Er1z\FakeMock\Generator\AssertGenerator;
4
5
use Er1z\FakeMock\Metadata\FieldMetadata;
6
use Faker\Generator;
7
use Symfony\Component\Validator\Constraint;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Validator\Constraint was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Component\Validator\Constraints\Ip as IpConstraint;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Validator\Constraints\Ip was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class Ip implements GeneratorInterface
11
{
12 6
    public function generateForProperty(FieldMetadata $field, Constraint $constraint, Generator $faker)
13
    {
14
        /*
15
         * @var IpConstraint
16
         */
17 6
        switch ($constraint->version) {
18 6
            case IpConstraint::V6:
19 3
            case IpConstraint::V6_NO_PRIV:
20 3
            case IpConstraint::V6_NO_RES:
21 3
            case IpConstraint::V6_ONLY_PUBLIC:
22 3
                return $faker->ipv6;
23
24
            default:
25 3
            case IpConstraint::V4:
26
            case IpConstraint::V4_NO_PRIV:
27
            case IpConstraint::V4_NO_RES:
28
            case IpConstraint::V4_ONLY_PUBLIC:
29 3
                return $faker->ipv4;
30
31
            case IpConstraint::ALL:
32
            case IpConstraint::ALL_NO_PRIV:
33
            case IpConstraint::ALL_NO_RES:
34
            case IpConstraint::ALL_ONLY_PUBLIC:
35
                return $faker->{mt_rand(0, 1) ? 'ipv4' : 'ipv6'};
36
        }
37
    }
38
}
39