ConfigurationNotSupportedException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A withName() 0 5 1
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AnthillBundle\Exception\Vacancy\Roadmap;
17
18
use RuntimeException;
19
use Symfony\Component\HttpFoundation\Response;
20
use Throwable;
21
use Veslo\AnthillBundle\Exception\AnthillBundleExceptionInterface;
22
use Veslo\AnthillBundle\Vacancy\ConfigurableRoadmapInterface;
23
24
/**
25
 * Will be thrown if roadmap doesn't support configuration
26
 *
27
 * @see ConfigurableRoadmapInterface
28
 */
29
class ConfigurationNotSupportedException extends RuntimeException implements AnthillBundleExceptionInterface
30
{
31
    /**
32
     * Default error message
33
     *
34
     * @const string
35
     */
36
    public const MESSAGE = 'Configuration of roadmap is not supported.';
37
38
    /**
39
     * Error message with name of roadmap that doesn't support configuration
40
     *
41
     * @const string
42
     */
43
    public const MESSAGE_WITH_NAME = "Configuration of roadmap '{roadmapName}' is not supported.";
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function __construct(
49
        string $message = self::MESSAGE,
50
        int $code = Response::HTTP_INTERNAL_SERVER_ERROR,
51
        Throwable $previous = null
52
    ) {
53
        parent::__construct($message, $code, $previous);
54
    }
55
56
    /**
57
     * Returns exception in context of specified name
58
     *
59
     * @param string $roadmapName Roadmap name
60
     *
61
     * @return ConfigurationNotSupportedException
62
     */
63
    public static function withName(string $roadmapName): ConfigurationNotSupportedException
64
    {
65
        $message = str_replace('{roadmapName}', $roadmapName, self::MESSAGE_WITH_NAME);
66
67
        return new static($message);
68
    }
69
}
70