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

BlockNotPresentException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 9
c 1
b 1
f 0
dl 0
loc 14
rs 9.9666
cc 1
nc 1
nop 3
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