Passed
Push — master ( 6cfdb1...d9c2c2 )
by Sergei
02:31
created

incorrectArrayDefinitionMethodArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 8
ccs 7
cts 7
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Definitions\Helpers;
6
7
use Yiisoft\Definitions\Exception\InvalidConfigException;
8
9
/**
10
 * @internal
11
 */
12
final class ExceptionHelper
13
{
14 2
    public static function invalidArrayDefinitionKey(int|string $key): InvalidConfigException
15
    {
16 2
        return new InvalidConfigException(
17 2
            sprintf(
18 2
                'Invalid definition: invalid key in array definition. Only string keys are allowed, got %d.',
19 2
                $key,
20 2
            ),
21 2
        );
22
    }
23
24 3
    public static function incorrectArrayDefinitionConstructorArguments(mixed $value): InvalidConfigException
25
    {
26 3
        return new InvalidConfigException(
27 3
            sprintf(
28 3
                'Invalid definition: incorrect constructor arguments. Expected array, got %s.',
29 3
                get_debug_type($value)
30 3
            )
31 3
        );
32
    }
33
34 3
    public static function incorrectArrayDefinitionMethodArguments(string $key, mixed $value): InvalidConfigException
35
    {
36 3
        return new InvalidConfigException(
37 3
            sprintf(
38 3
                'Invalid definition: incorrect method "%s" arguments. Expected array, got "%s". ' .
39 3
                'Probably you should wrap them into square brackets.',
40 3
                $key,
41 3
                get_debug_type($value),
42 3
            )
43 3
        );
44
    }
45
}
46