-
Notifications
You must be signed in to change notification settings - Fork 1
/
InvalidAttributeException.php
64 lines (52 loc) · 1.24 KB
/
InvalidAttributeException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Deserializers\Exceptions;
use Exception;
/**
* A deserialization exception that is thrown when an expected array key is present, but it's value
* is not in the expected format.
*
* @since 1.0
*
* @license GPL-2.0+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
* @author Thiemo Mättig
*/
class InvalidAttributeException extends DeserializationException {
protected $attributeName;
protected $attributeValue;
/**
* @param string $attributeName
* @param mixed $attributeValue
* @param string $message
* @param Exception|null $previous
*/
public function __construct(
$attributeName,
$attributeValue,
$message = '',
Exception $previous = null
) {
$this->attributeName = $attributeName;
$this->attributeValue = $attributeValue;
if ( $message === '' ) {
$message = 'Attribute "' . $attributeName . '"';
if ( is_scalar( $attributeValue ) ) {
$message .= ' with value "' . $attributeValue . '"';
}
$message .= ' is invalid';
}
parent::__construct( $message, $previous );
}
/**
* @return string
*/
public function getAttributeName() {
return $this->attributeName;
}
/**
* @return string
*/
public function getAttributeValue() {
return $this->attributeValue;
}
}