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

InvalidArgumentException::getConstraints()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Assert
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD 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 InvalidArgumentException extends \InvalidArgumentException implements AssertionFailedException
17
{
18
    private $propertyPath;
19
    private $value;
20
    private $constraints;
21
22
    public function __construct($message, $code, $propertyPath = null, $value, array $constraints = array())
0 ignored issues
show
Coding Style introduced by
Parameters which have default values should be placed at the end.

If you place a parameter with a default value before a parameter with a default value, the default value of the first parameter will never be used as it will always need to be passed anyway:

// $a must always be passed; it's default value is never used.
function someFunction($a = 5, $b) { }
Loading history...
23
    {
24
        parent::__construct($message, $code);
25
26
        $this->propertyPath = $propertyPath;
27
        $this->value = $value;
28
        $this->constraints = $constraints;
29
    }
30
31
    /**
32
     * User controlled way to define a sub-property causing
33
     * the failure of a currently asserted objects.
34
     *
35
     * Useful to transport information about the nature of the error
36
     * back to higher layers.
37
     *
38
     * @return string
39
     */
40
    public function getPropertyPath()
41
    {
42
        return $this->propertyPath;
43
    }
44
45
    /**
46
     * Get the value that caused the assertion to fail.
47
     *
48
     * @return mixed
49
     */
50
    public function getValue()
51
    {
52
        return $this->value;
53
    }
54
55
    /**
56
     * Get the constraints that applied to the failed assertion.
57
     *
58
     * @return array
59
     */
60
    public function getConstraints()
61
    {
62
        return $this->constraints;
63
    }
64
}
65
66