Completed
Branch master (69a8ae)
by Roman
02:48
created

InvalidSameValueException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 28
ccs 14
cts 14
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 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 InvalidSameValueException extends ArgumentException
11
{
12
    /**
13
     * @param string                        $variableName
14
     * @param int|float|bool|resource|array $variableValue
15
     * @param int|float|bool|resource|array $anotherValue
16
     * @throws InvalidNotEmptyException
17
     * @throws InvalidStringException
18
     * @throws InvalidNotSameValueException
19
     */
20 4
    public function __construct($variableName, $variableValue, $anotherValue)
21
    {
22 4
        if (!is_string($variableName)) {
23 1
            throw new InvalidStringException('variableName', $variableName);
24 3
        } elseif ($variableValue === $anotherValue) {
25 1
            throw new InvalidNotSameValueException('variableValue', $variableValue);
26
        }
27
28 3
        parent::__construct(
29 3
            sprintf(
30 3
                'Variable "$%s" must be same as: "%s", actual value: "%s"',
31 3
                $variableName,
32 3
                print_r($anotherValue, true),
33 3
                print_r($variableValue, true)
34 3
            )
35 3
        );
36 3
    }
37
}
38