Completed
Push — master ( a8c051...1e2ea2 )
by Delete
02:24
created

InvalidArgumentException::getInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
nc 1
nop 4
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
1
<?php
2
namespace Crossjoin\Json\Exception;
3
4
/**
5
 * Class InvalidArgumentException
6
 *
7
 * @package Crossjoin\Json\Exception
8
 * @author Christoph Ziegenberg <[email protected]>
9
 */
10
class InvalidArgumentException extends \InvalidArgumentException implements JsonException
11
{
12
    /** @noinspection MoreThanThreeArgumentsInspection */
13
    /**
14
     * @param string $expectedType
15
     * @param string $argumentName
16
     * @param mixed $currentValue
17
     * @param int $code
18
     *
19
     * @return InvalidArgumentException
20
     */
21
    public static function getInstance($expectedType, $argumentName, $currentValue, $code = 0)
22
    {
23
        return new self(
24
            sprintf(
25
                "%s expected for argument '%s'. Got '%s'.",
26
                ucfirst(strtolower($expectedType)),
27
                $argumentName,
28
                gettype($currentValue)
29
            ),
30
            $code
31
        );
32
    }
33
}
34