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

FileNotWritableException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 32
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fromInvalidMoveOperation() 0 9 1
A fromNotWritableDirectory() 0 8 1
A fromPrevious() 0 4 1
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