Passed
Pull Request — master (#149)
by Pierre
03:06
created

DictionaryNotFoundException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 3
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Knp\DictionaryBundle\Exception;
6
7
use Exception;
8
9
final class DictionaryNotFoundException extends Exception
10
{
11
    /**
12
     * @param string[] $knowns
13
     */
14 3
    public function __construct(string $dictionaryName, array $knowns = [], Exception $previous = null)
15
    {
16 3
        $message = sprintf('The dictionary "%s" has not been found in the registry.', $dictionaryName);
17
18 3
        if (!empty($knowns)) {
19 1
            $message .= sprintf(' Known dictionaries are: "%s".', implode('", "', $knowns));
20
        }
21
22 3
        parent::__construct($message, 0, $previous);
23 3
    }
24
}
25