UnexpectedTypeException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php
2
3
namespace FigTree\Exceptions;
4
5
use Throwable;
6
7
/**
8
 * Exception thrown when a value is not of an expected type.
9
 */
10
class UnexpectedTypeException extends LogicException
11
{
12
	/**
13
	 * Exception thrown when a value is not of an expected type.
14
	 *
15
	 * @param mixed $value Actual value.
16
	 * @param string $expected The name of the expected type.
17
	 * @param int $code The Exception code.
18
	 * @param \Throwable $previous The previous throwable used for the exception chaining.
19
	 */
20
	public function __construct($value, string $expected, int $code = 0, Throwable $previous = null)
21
	{
22
		$message = sprintf(
23
			'Expected value of type %s; %s given.',
24
			$expected,
25
			(is_object($value) ? get_class($value) : gettype($value))
26
		);
27
28
		parent::__construct($message, $code, $previous);
29
	}
30
}
31