Completed
Push — master ( f74359...e7cb9d )
by Marco
37:27 queued 12:15
created

FileNotWritableException::fromPrevious()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\Exception;
6
7
use UnexpectedValueException;
8
use Webimpress\SafeWriter\Exception\ExceptionInterface as FileWriterException;
9
use function sprintf;
10
11
/**
12
 * Exception for non writable files
13
 */
14
class FileNotWritableException extends UnexpectedValueException implements ExceptionInterface
15
{
16 1
    /**
17
     * @deprecated
18 1
     */
19
    public static function fromInvalidMoveOperation(string $fromPath, string $toPath) : self
20 1
    {
21 1
        return new self(sprintf(
22 1
            'Could not move file "%s" to location "%s": '
23
            . 'either the source file is not readable, or the destination is not writable',
24
            $fromPath,
25
            $toPath
26 1
        ));
27
    }
28 1
29
    /**
30 1
     * @deprecated
31 1
     */
32
    public static function fromNotWritableDirectory(string $directory) : self
33
    {
34
        return new self(sprintf(
35
            'Could not create temp file in directory "%s" '
36
            . 'either the directory does not exist, or it is not writable',
37
            $directory
38
        ));
39
    }
40
41
    public static function fromPrevious(FileWriterException $previous) : self
42
    {
43
        return new self($previous->getMessage(), 0, $previous);
44
    }
45
}
46