BlockException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 2
b 0
f 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A forEmptyName() 0 3 1
A forEmptyTemplate() 0 3 1
A forNotFoundTemplate() 0 4 1
1
<?php
2
3
namespace Helick\Blocks\Exceptions;
4
5
use InvalidArgumentException;
6
7
final class BlockException extends InvalidArgumentException
8
{
9
    /**
10
     * @return BlockException
11
     */
12
    public static function forEmptyName(): self
13
    {
14
        return new static('You must set the block name before composing');
15
    }
16
17
    /**
18
     * @return BlockException
19
     */
20
    public static function forEmptyTemplate(): self
21
    {
22
        return new static('You must set the block template before rendering');
23
    }
24
25
    /**
26
     * @param string|string[] $template
27
     *
28
     * @return BlockException
29
     */
30
    public static function forNotFoundTemplate($template): self
31
    {
32
        return new static(strtr('The block template ":template" could not be found', [
33
            ':template' => implode(', ', (array)$template)
34
        ]));
35
    }
36
}
37