ValueNotInArrayException::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 17
ccs 14
cts 14
cp 1
rs 9.4285
cc 3
eloc 11
nc 3
nop 3
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 ValueNotInArrayException extends ArgumentException
11
{
12
    /**
13
     * @param string $variableName
14
     * @param mixed  $variableValue
15
     * @param array  $array
16
     * @throws InvalidArrayException
17
     * @throws InvalidStringException
18
     */
19 4
    public function __construct($variableName, $variableValue, $array)
20
    {
21 4
        if (!is_string($variableName)) {
22 1
            throw new InvalidStringException('variableName', $variableName);
23 3
        } elseif (!is_array($array)) {
24 1
            throw new InvalidArrayException('array', $array);
25
        }
26
27 2
        parent::__construct(
28 2
            sprintf(
29 2
                'Variable "$%s" must be "in array" {%s}, actual value: "%s"',
30 2
                $variableName,
31 2
                print_r($array, true),
32 2
                print_r($variableValue, true)
33 2
            )
34 2
        );
35
    }
36
}