Completed
Push — master ( 8a9ad2...75b1ab )
by Richard
02:40
created

LazyAssertionException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
cbo 1
dl 0
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorExceptions() 0 4 1
A fromErrors() 0 11 2
A __construct() 0 6 1
1
<?php
2
/**
3
 * Assert
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the MIT license that is bundled
8
 * with this package in the file LICENSE.txt.
9
 * If you did not receive a copy of the license and are unable to
10
 * obtain it through the world-wide-web, please send an email
11
 * to [email protected] so I can send you a copy immediately.
12
 */
13
14
namespace Assert;
15
16
class LazyAssertionException extends \InvalidArgumentException
17
{
18
    /**
19
     * @var InvalidArgumentException[]
20
     */
21
    private $errors = array();
22
23
    /**
24
     * @param InvalidArgumentException[] $errors
25
     * @return self
26
     */
27
    static public function fromErrors(array $errors)
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
28
    {
29
        $message = sprintf('The following %d assertions failed:' , count($errors)) . "\n";
0 ignored issues
show
Coding Style introduced by
Space found before comma in function call
Loading history...
30
31
        $i = 1;
32
        foreach ($errors as $error) {
33
            $message .= sprintf("%d) %s: %s\n", $i++, $error->getPropertyPath(), $error->getMessage());
34
        }
35
36
        return new self($message, $errors);
37
    }
38
39
    public function __construct($message, array $errors)
40
    {
41
        parent::__construct($message, 0);
42
43
        $this->errors = $errors;
44
    }
45
46
    public function getErrorExceptions()
47
    {
48
        return $this->errors;
49
    }
50
}
51