RouteInvalidConfigurationException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 14
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Http\Exception;
15
16
/**
17
 * @author Stanislau Komar <[email protected]>
18
 */
19
class RouteInvalidConfigurationException extends RouteConfigurationException
20
{
21
    /**
22
     * @var string[]
23
     */
24
    private array $messages;
25
26
    /**
27
     * @param string[] $messages
28
     */
29
    public function __construct(string $routeName, array $messages, int $code = 0, ?\Throwable $previous = null)
30
    {
31
        $message = <<<EOF
32
            Invalid route "%s" configuration:
33
                * %s
34
        EOF;
35
36
        $message = sprintf($message, $routeName, implode("\r\n        * ", $messages));
37
38
        $this->messages = $messages;
39
        parent::__construct(
40
            $message,
41
            $code,
42
            $previous
43
        );
44
    }
45
46
    /**
47
     * @return string[]
48
     */
49
    public function getMessages(): array
50
    {
51
        return $this->messages;
52
    }
53
}
54