NumberNotPositiveException::__construct()   A
last analyzed

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