Completed
Push — master ( bc831c...e6e5a9 )
by Alejandro
16s queued 11s
created

DbUpdateException::forFailedExtraction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\IpGeolocation\Exception;
6
7
use Throwable;
8
9
use function sprintf;
10
11
class DbUpdateException extends RuntimeException
12
{
13 2
    public static function forFailedDownload(Throwable $prev): self
14
    {
15 2
        return self::build('An error occurred while trying to download a fresh copy of the GeoLite2 database', $prev);
16
    }
17
18 2
    public static function forFailedExtraction(string $compressedFile, Throwable $prev): self
19
    {
20 2
        return self::build(
21 2
            sprintf('An error occurred while trying to extract the GeoLite2 database from %s', $compressedFile),
22
            $prev,
23
        );
24
    }
25
26 3
    public static function forFailedCopyToDestination(string $destination, Throwable $prev): self
27
    {
28 3
        return self::build(
29 3
            sprintf('An error occurred while trying to copy GeoLite2 db file to %s folder', $destination),
30
            $prev,
31
        );
32
    }
33
34 7
    private static function build(string $message, Throwable $prev): self
35
    {
36 7
        return new self($message, 0, $prev);
37
    }
38
}
39