Passed
Branch 0.x (5dcc76)
by Pavel
03:30
created

BadProxyListUriException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A withProxyListUri() 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\AppBundle\Exception\Http\Proxy\Locator;
17
18
use RuntimeException;
19
use Throwable;
20
use Veslo\AppBundle\Exception\AppBundleExceptionInterface;
21
22
/**
23
 * Will be thrown if locator isn't able to get contents of specified proxy list URI
24
 */
25
class BadProxyListUriException extends RuntimeException implements AppBundleExceptionInterface
26
{
27
    /**
28
     * Default error message
29
     *
30
     * @const string
31
     */
32
    public const MESSAGE = 'Cannot locate a proxy list by specified URI.';
33
34
    /**
35
     * Error message with proxy list URI
36
     *
37
     * @const string
38
     */
39
    public const MESSAGE_WITH_PROXY_LIST_URI = "Cannot locate a proxy list by specified URI '{proxyListUri}'.";
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function __construct(string $message = self::MESSAGE, int $code = 0, Throwable $previous = null)
45
    {
46
        parent::__construct($message, $code, $previous);
47
    }
48
49
    /**
50
     * Returns exception in context of specified proxy list URI
51
     *
52
     * @param string $proxyListUri Proxy list URI
53
     *
54
     * @return BadProxyListUriException
55
     */
56
    public static function withProxyListUri(string $proxyListUri): BadProxyListUriException
57
    {
58
        $message = str_replace('{proxyListUri}', $proxyListUri, self::MESSAGE_WITH_PROXY_LIST_URI);
59
60
        return new static($message);
61
    }
62
}
63