Completed
Push — master ( e24db7...5dd27b )
by Matt
02:58
created

MinProperties::validate()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 2
nop 3
dl 14
loc 14
ccs 10
cts 10
cp 1
crap 3
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace League\JsonGuard\Constraints;
4
5
use League\JsonGuard;
6
use League\JsonGuard\ValidationError;
7
8 View Code Duplication
class MinProperties implements PropertyConstraint
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    const KEYWORD = 'minProperties';
11
12
    /**
13
     * {@inheritdoc}
14
     */
15 4
    public static function validate($value, $min, $pointer = null)
16
    {
17 4
        if (!is_object($value) || count(get_object_vars($value)) >= $min) {
18 4
            return null;
19
        }
20
21 4
        return new ValidationError(
22 4
            'Object does not contain at least {min_properties} properties',
23 4
            self::KEYWORD,
24 4
            $value,
25 4
            $pointer,
26 4
            ['min_properties' => $min]
27 4
        );
28
    }
29
}
30