Completed
Push — master ( 6410b3...aeeaf1 )
by Joachim
04:38
created

BlockNotPresentException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
eloc 15
c 1
b 1
f 0
dl 0
loc 43
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A getDefinedBlocks() 0 3 1
A getBlock() 0 3 1
A getTemplate() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusStockMovementPlugin\Exception;
6
7
use InvalidArgumentException;
8
use Safe\Exceptions\StringsException;
9
use function Safe\sprintf;
10
11
final class BlockNotPresentException extends InvalidArgumentException implements ExceptionInterface
12
{
13
    /** @var string */
14
    private $block;
15
16
    /** @var array */
17
    private $definedBlocks;
18
19
    /** @var string */
20
    private $template;
21
22
    /**
23
     * @throws StringsException
24
     */
25
    public function __construct(string $block, array $definedBlocks, string $template)
26
    {
27
        $this->block = $block;
28
        $this->definedBlocks = $definedBlocks;
29
        $this->template = $template;
30
31
        $message = sprintf(
32
            'The block "%s" is not present in the defined blocks ["%s"] of your template %s',
33
            $this->block,
34
            implode('", "', $this->definedBlocks),
35
            $this->template
36
        );
37
38
        parent::__construct($message);
39
    }
40
41
    public function getBlock(): string
42
    {
43
        return $this->block;
44
    }
45
46
    public function getDefinedBlocks(): array
47
    {
48
        return $this->definedBlocks;
49
    }
50
51
    public function getTemplate(): string
52
    {
53
        return $this->template;
54
    }
55
}
56