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

InvalidTemplateFormatException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 15
ccs 6
cts 7
cp 0.8571
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 2
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