Invalid   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getErrors() 0 4 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Caridea
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7
 * use this file except in compliance with the License. You may obtain a copy of
8
 * the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
 * License for the specific language governing permissions and limitations under
16
 * the License.
17
 *
18
 * @copyright 2015-2018 LibreWorks contributors
19
 * @license   Apache-2.0
20
 */
21
namespace Caridea\Validate\Exception;
22
23
/**
24
 * Validation Exception
25
 *
26
 * @copyright 2015-2018 LibreWorks contributors
27
 * @license   Apache-2.0
28
 */
29
class Invalid extends \UnexpectedValueException implements \Caridea\Validate\Exception
30
{
31
    /**
32
     * @var array $errors Associative array of field name to error
33
     */
34
    private $errors;
35
36
    /**
37
     * Creates a new Validation exception.
38
     *
39
     * @param array $errors Associative array of field name to error
40
     */
41 1
    public function __construct(array $errors)
42
    {
43 1
        parent::__construct("Validation failed: " . json_encode($errors));
44 1
        $this->errors = $errors;
45 1
    }
46
    
47
    /**
48
     * Gets the failed validation errors.
49
     *
50
     * @return array Associative array of field name to error
51
     */
52 1
    public function getErrors(): array
53
    {
54 1
        return $this->errors;
55
    }
56
}
57