Nested   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
dl 0
loc 27
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 1
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isValidArray() 0 13 3
A getInvalidDetails() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the Valdi package.
5
 *
6
 * (c) Philip Lehmann-Böhm <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Valdi\Validator;
13
14
use Valdi\Validator;
15
16
/**
17
 * Validator for nested data sets.
18
 */
19
class Nested extends AbstractArray
20
{
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 3
    protected function isValidArray($values, Validator $validator, array $rules)
26
    {
27 3
        if (!is_array($values)) {
28 1
            $this->invalidDetails = $values;
29 1
            return false;
30
        }
31
32 3
        $elementValidation = $validator->isValid($rules, $values);
33 3
        if (!$elementValidation['valid']) {
34 2
            $this->invalidDetails = $elementValidation['errors'];
35 2
            return false;
36
        }
37 2
        return true;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 1
    public function getInvalidDetails()
44
    {
45 1
        return ['nested' => $this->invalidDetails];
46
    }
47
}
48