Completed
Push — master ( 379576...3184a2 )
by Roman
02:29
created

NumberNotBetweenStrictlyException::__construct()   C

Complexity

Conditions 8
Paths 5

Size

Total Lines 22
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 8

Importance

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