MissingAttributeException::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 3
ccs 6
cts 6
cp 1
crap 2
1
<?php
2
3
namespace Deserializers\Exceptions;
4
5
use Exception;
6
7
/**
8
 * A deserialization exception that is thrown when an expected array key is not present.
9
 *
10
 * @since 1.0
11
 *
12
 * @license GPL-2.0-or-later
13
 * @author Jeroen De Dauw < [email protected] >
14
 * @author Thiemo Kreuz
15
 */
16
class MissingAttributeException extends DeserializationException {
17
18
	private $attributeName;
19
20
	/**
21
	 * @param string $attributeName
22
	 * @param string $message
23
	 * @param Exception|null $previous
24
	 */
25 2
	public function __construct( $attributeName, $message = '', Exception $previous = null ) {
26 2
		$this->attributeName = $attributeName;
27
28 2
		if ( $message === '' ) {
29 1
			$message = 'Attribute "' . $attributeName . '" is missing';
30
		}
31
32 2
		parent::__construct( $message, $previous );
33 2
	}
34
35
	/**
36
	 * @return string
37
	 */
38 2
	public function getAttributeName() {
39 2
		return $this->attributeName;
40
	}
41
42
}
43