Completed
Pull Request — master (#438)
by
unknown
03:20
created

FileNotWritableException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 55.56%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 21
ccs 5
cts 9
cp 0.5556
rs 10
c 0
b 0
f 0

2 Methods

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