Completed
Branch master (69a8ae)
by Roman
02:48
created

ArrayKeyNotExistsException::__construct()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4

Importance

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