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

NotValidUrlException::message()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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