InvalidNumericException   A
last analyzed

Complexity

Total Complexity 5

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 5
c 2
b 0
f 2
lcom 0
cbo 3
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 16 5
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 InvalidNumericException extends ArgumentException
11
{
12
    /**
13
     * @param string $variableName
14
     * @param int    $variableValue
15
     * @throws InvalidIntOrFloatOrStringException
16
     * @throws InvalidStringException
17
     */
18 6
    public function __construct($variableName, $variableValue)
19
    {
20 6
        if (!is_string($variableName)) {
21 1
            throw new InvalidStringException('variableName', $variableName);
22 5
        } elseif (!is_int($variableValue) && !is_float($variableValue) && !is_string($variableValue)) {
23 1
            throw new InvalidIntOrFloatOrStringException('variableValue', $variableValue);
24
        }
25
26 5
        parent::__construct(
27 5
            sprintf(
28 5
                'Variable "$%s" must be "numeric", actual value: "%s"',
29 5
                $variableName,
30
                (string) $variableValue
31 5
            )
32 5
        );
33
    }
34
}