Completed
Push — master ( 379576...3184a2 )
by Roman
02:29
created

InvalidArrayException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 3
c 2
b 0
f 2
lcom 0
cbo 3
dl 0
loc 25
ccs 13
cts 13
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 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 8
    public function __construct($variableName, $variableValue)
19
    {
20 8
        if (!is_string($variableName)) {
21 1
            throw new InvalidStringException('variableName', $variableName);
22 7
        } elseif (is_array($variableValue)) {
23 1
            throw new InvalidNotArrayException('variableValue', $variableValue);
1 ignored issue
show
Unused Code introduced by
The call to InvalidNotArrayException::__construct() has too many arguments starting with $variableValue.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
24
        }
25
26 7
        parent::__construct(
27 7
            sprintf(
28 7
                'Variable "$%s" must be "array", actual type: "%s"',
29 7
                $variableName,
30 7
                gettype($variableValue)
31 7
            )
32 7
        );
33
    }
34
}