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

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