InvalidArgumentException::fromInvalidLogLevel()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Amesplash\CampaignMonitorLog\Exception;
5
6
class InvalidArgumentException extends \Psr\Log\InvalidArgumentException
7
{
8 5
    public static function fromInvalidLogLevel(
9
        $level,
10
        $allowedTypes = [1000, 500, 250]
11
    ) : self {
12 5
        $argument = is_object($level) ? get_class($level) : gettype($level);
13
14 5
        $message = sprintf(
15 5
            'Argument "%s" is invalid. Allowed log levels are "%s".',
16
            $argument,
17 5
            implode(', ', $allowedTypes)
18
        );
19
20 5
        return new self($message);
21
    }
22
}
23