InvalidStringException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 3
c 2
b 0
f 2
lcom 0
cbo 2
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 InvalidStringException extends ArgumentException
11
{
12
    /**
13
     * @param string                             $variableName
14
     * @param array|bool|float|int|null|resource $variableValue
15
     * @throws InvalidNotStringException
16
     * @throws InvalidStringException
17
     */
18 72
    public function __construct($variableName, $variableValue)
19
    {
20 72
        if (!is_string($variableName)) {
21 1
            throw new InvalidStringException('variableName', $variableName);
22 72
        } elseif (is_string($variableValue)) {
23 1
            throw new InvalidNotStringException('variableValue');
24
        }
25
26 72
        parent::__construct(
27 72
            sprintf(
28 72
                'Variable "$%s" must be "string", actual type: "%s"',
29 72
                $variableName,
30 72
                gettype($variableValue)
31 72
            )
32 72
        );
33
    }
34
}