Passed
Push — master ( fa8c08...0a6b13 )
by Joachim
03:11
created

TemplateNotFoundException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 2
eloc 6
c 2
b 0
f 1
nc 2
nop 2
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
crap 2.0185
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\PhpTemplates\Exception;
6
7
use InvalidArgumentException;
8
use function Safe\sprintf;
9
10
final class TemplateNotFoundException extends InvalidArgumentException implements ExceptionInterface
11
{
12 2
    public function __construct(string $template, array $paths)
13
    {
14 2
        $message = sprintf('The template, "%s" was not found.', $template);
15
16 2
        if (count($paths) > 0) {
17 2
            $message .= sprintf(' Looked inside these paths (in this order): %s', implode(', ', $paths));
18
        } else {
19
            $message .= ' No paths has been added to the engine. Use the Setono\PhpTemplates\Engine\EngineInterface::addPath() method to do so.';
20
        }
21
22 2
        parent::__construct($message);
23 2
    }
24
}
25