UnexpectedTypeException::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 9.4285
cc 3
eloc 5
nc 1
nop 2
crap 3
1
<?php
2
3
namespace Crummy\Phlack\Common\Exception;
4
5
class UnexpectedTypeException extends \InvalidArgumentException
6
{
7
    /**
8
     * @param mixed        $value
9
     * @param string|array $expectedType
10
     */
11 2
    public function __construct($value, $expectedType)
12
    {
13 2
        parent::__construct(sprintf(
14 2
            'Expected argument of type %s, %s given.',
15 2
            is_array($expectedType) ? '('.implode(' | ', $expectedType).')' : $expectedType,
16 2
            is_object($value) ? get_class($value) : gettype($value)
17 2
        ));
18 2
    }
19
}
20