Nested::getInvalidDetails()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 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