Completed
Push — master ( 038254...115ca0 )
by Alejandro
06:27
created

GeolocationDbUpdateFailedException::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\CLI\Exception;
6
7
use RuntimeException;
8
use Throwable;
9
10
class GeolocationDbUpdateFailedException extends RuntimeException implements ExceptionInterface
11
{
12
    /** @var bool */
13
    private $olderDbExists;
14
15 18
    public function __construct(bool $olderDbExists, string $message = '', int $code = 0, ?Throwable $previous = null)
16
    {
17 18
        $this->olderDbExists = $olderDbExists;
18 18
        parent::__construct($message, $code, $previous);
19
    }
20
21 13
    public static function create(bool $olderDbExists, ?Throwable $prev = null): self
22
    {
23 13
        return new self(
24 13
            $olderDbExists,
25 13
            'An error occurred while updating geolocation database, and an older version could not be found',
26 13
            0,
27 13
            $prev
28
        );
29
    }
30
31 18
    public function olderDbExists(): bool
32
    {
33 18
        return $this->olderDbExists;
34
    }
35
}
36