InvalidArrayException::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 16
ccs 13
cts 13
cp 1
rs 9.4285
cc 3
eloc 10
nc 3
nop 2
crap 3
1
<?php
2
/**
3
 * @link      https://github.com/ko-ko-ko/php-assert
4
 * @copyright Copyright (c) 2015 Roman Levishchenko <[email protected]>
5
 * @license   https://raw.github.com/ko-ko-ko/php-assert/master/LICENSE
6
 */
7
8
namespace KoKoKo\assert\exceptions;
9
10
class InvalidArrayException extends ArgumentException
11
{
12
    /**
13
     * @param string                              $variableName
14
     * @param bool|float|int|null|resource|string $variableValue
15
     * @throws InvalidNotArrayException
16
     * @throws InvalidStringException
17
     */
18 11
    public function __construct($variableName, $variableValue)
19
    {
20 11
        if (!is_string($variableName)) {
21 1
            throw new InvalidStringException('variableName', $variableName);
22 10
        } elseif (is_array($variableValue)) {
23 1
            throw new InvalidNotArrayException('variableValue');
24
        }
25
26 10
        parent::__construct(
27 10
            sprintf(
28 10
                'Variable "$%s" must be "array", actual type: "%s"',
29 10
                $variableName,
30 10
                gettype($variableValue)
31 10
            )
32 10
        );
33
    }
34
}