NumberNotGreaterException::__construct()   B
last analyzed

Complexity

Conditions 6
Paths 4

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 19
ccs 15
cts 15
cp 1
rs 8.8571
cc 6
eloc 13
nc 4
nop 3
crap 6
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 NumberNotGreaterException extends ArgumentException
11
{
12
    /**
13
     * @param string    $variableName
14
     * @param int|float $variableValue
15
     * @param int|float $number
16
     * @throws InvalidIntOrFloatException
17
     * @throws InvalidStringException
18
     */
19 8
    public function __construct($variableName, $variableValue, $number)
20
    {
21 8
        if (!is_string($variableName)) {
22 1
            throw new InvalidStringException('variableName', $variableName);
23 7
        } elseif (!is_int($variableValue) && !is_float($variableValue)) {
24 1
            throw new InvalidIntOrFloatException('variableValue', $variableValue);
25 7
        } elseif (!is_int($number) && !is_float($number)) {
26 1
            throw new InvalidIntOrFloatException('number', $number);
27
        }
28
29 7
        parent::__construct(
30 7
            sprintf(
31 7
                'Variable "$%s" must be greater than "%s", actual value: "%s"',
32 7
                $variableName,
33 7
                (string) $number,
34
                (string) $variableValue
35 7
            )
36 7
        );
37
    }
38
}