MissingAttributeException::getAttributeName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
ccs 2
cts 2
cp 1
crap 1
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