InvalidArgumentException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A invalidType() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\Exception;
6
7
use InvalidArgumentException as BuiltinInvalidArgumentException;
8
9
use function get_class;
10
use function gettype;
11
use function is_object;
12
use function sprintf;
13
14
class InvalidArgumentException extends BuiltinInvalidArgumentException
15
{
16
    /**
17
     * @param string $expected description of expected type
18
     * @param mixed  $parameter the parameter that is not of the expected type.
19
     *
20
     * @return \SimpleSAML\SAML2\Exception\InvalidArgumentException
21
     */
22
    public static function invalidType(string $expected, $parameter): InvalidArgumentException
23
    {
24
        $message = sprintf(
25
            'Invalid Argument type: "%s" expected, "%s" given',
26
            $expected,
27
            is_object($parameter) ? get_class($parameter) : gettype($parameter),
28
        );
29
30
        return new self($message);
31
    }
32
}
33