Passed
Push — main ( 35cea8...263c2f )
by Andrey
21:51 queued 20:06
created

NotValidUrlException   A

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
namespace Helldar\Support\Exceptions;
4
5
use Exception;
6
7
class NotValidUrlException extends Exception
8
{
9 14
    public function __construct(?string $url)
10
    {
11 14
        $value = $this->value($url);
12
13 14
        $message = $this->message($value);
14
15 14
        parent::__construct($message, 412);
16 14
    }
17
18 14
    protected function value(?string $url): string
19
    {
20 14
        if (! empty($url)) {
21 6
            return 'The "' . $url . '"';
22
        }
23
24 8
        return 'Empty string';
25
    }
26
27 14
    protected function message(string $value): string
28
    {
29 14
        return $value . ' is not a valid URL.';
30
    }
31
}
32