NotValidUrlException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A message() 0 3 1
A value() 0 7 2
1
<?php
2
/*
3
 * This file is part of the "andrey-helldar/support" project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author Andrey Helldar <[email protected]>
9
 *
10
 * @copyright 2021 Andrey Helldar
11
 *
12
 * @license MIT
13
 *
14
 * @see https://github.com/andrey-helldar/support
15
 */
16
17
namespace Helldar\Support\Exceptions;
18
19
use Exception;
20
21
class NotValidUrlException extends Exception
22
{
23 14
    public function __construct(?string $url)
24
    {
25 14
        $value = $this->value($url);
26
27 14
        $message = $this->message($value);
28
29 14
        parent::__construct($message, 412);
30 14
    }
31
32 14
    protected function value(?string $url): string
33
    {
34 14
        if (! empty($url)) {
35 7
            return 'The "' . $url . '"';
36
        }
37
38 7
        return 'Empty string';
39
    }
40
41 14
    protected function message(string $value): string
42
    {
43 14
        return $value . ' is not a valid URL.';
44
    }
45
}
46