Completed
Pull Request — master (#402)
by Alejandro
05:51
created

GeolocationDbUpdateFailedException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 24
rs 10
c 0
b 0
f 0
ccs 11
cts 11
cp 1

3 Methods

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