Passed
Push — master ( 0a6b13...f8bee4 )
by Joachim
03:00
created

InvalidTemplateFormatException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 13
ccs 6
cts 7
cp 0.8571
crap 2.0116
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 InvalidTemplateFormatException extends InvalidArgumentException implements ExceptionInterface
11
{
12 1
    public function __construct(string $template, string $regexToMatch = null)
13
    {
14 1
        $message = sprintf(
15 1
            'The template, "%s", does not have the correct format.', $template
16
        );
17
18 1
        if (null === $regexToMatch) {
19 1
            $message .= ' Use "@Namespace/template.ext"';
20
        } else {
21
            $message .= sprintf(' The format must match this regex: %s', $regexToMatch);
22
        }
23
24 1
        parent::__construct($message);
25 1
    }
26
}
27