MissingAttributeException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getAttributeName() 0 3 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