Completed
Push — master ( 529067...858b09 )
by Peter
20s queued 11s
created

FileAccessException::failedCreateUnique()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Component\Sitemap\Stream\Exception;
11
12
class FileAccessException extends \RuntimeException
13
{
14
    /**
15
     * @param string $filename
16
     *
17
     * @return static
18
     */
19 1
    final public static function notWritable($filename)
20
    {
21 1
        return new static(sprintf('File "%s" is not writable.', $filename));
22
    }
23
24
    /**
25
     * @param string $filename
26
     *
27
     * @return static
28
     */
29 2
    final public static function notReadable($filename)
30
    {
31 2
        return new static(sprintf('File "%s" is not readable.', $filename));
32
    }
33
34
    /**
35
     * @param string $tmp_filename
36
     * @param string $target_filename
37
     *
38
     * @return self
39
     */
40 1
    final public static function failedOverwrite($tmp_filename, $target_filename)
41
    {
42 1
        return new self(sprintf(
43 1
            'Failed to overwrite file "%s" from temporary file "%s".',
44 1
            $target_filename,
45
            $tmp_filename
46 1
        ));
47
    }
48
49
    /**
50
     * @param string $path
51
     * @param string $prefix
52
     *
53
     * @return self
54
     */
55 1
    final public static function failedCreateUnique($path, $prefix)
56
    {
57 1
        return new self(sprintf(
58 1
            'Failed create file with unique file name in folder "%s" with prefix "%s".',
59 1
            $path,
60
            $prefix
61 1
        ));
62
    }
63
}
64