Completed
Pull Request — master (#438)
by
unknown
09:55
created

fromNotWritableDirectory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 4
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 function sprintf;
9
10
/**
11
 * Exception for non writable files
12
 *
13
 */
14
class FileNotWritableException extends UnexpectedValueException implements ExceptionInterface
15
{
16 1
    public static function fromInvalidMoveOperation(string $fromPath, string $toPath) : self
17
    {
18 1
        return new self(sprintf(
19
            'Could not move file "%s" to location "%s": '
20 1
            . 'either the source file is not readable, or the destination is not writable',
21 1
            $fromPath,
22 1
            $toPath
23
        ));
24
    }
25
26
    public static function fromNotWritableDirectory(string $directory) : self
27
    {
28
        return new self(sprintf(
29
            'Could not create temp file in directory "%s" '
30
            . 'either the directory does not exist, or it is not writable',
31
            $directory
32
        ));
33
    }
34
}
35