StringNotMatchRegExpException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

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