Completed
Push — master ( e3a6ad...a80db0 )
by Krishnaprasad
04:55
created

ClamavValidatorException::forClientException()   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 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Sunspikes\ClamavValidator;
4
5
use Exception;
6
7
class ClamavValidatorException extends Exception
8
{
9
    /**
10
     * @param string $file
11
     */
12 1
    public static function forNonReadableFile($file)
13
    {
14 1
        return new self(
15 1
            sprintf('The file "%s" is not readable', $file)
16 1
        );
17
    }
18
19
    /**
20
     * @param array $result
21
     */
22
    public static function forScanResult($result)
23
    {
24
        return new self(
25
            sprintf(
26
                'ClamAV scanner failed to scan file "%s" with error "%s" (%s)',
27
                $result['filename'],
28
                $result['reason'],
29
                $result['status']
30
            )
31
        );
32
    }
33
34
    /**
35
     * @param \Exception $exception
36
     */
37
    public static function forClientException($exception)
38
    {
39
        return new self(
40
            sprintf('ClamAV scanner client failed with error "%s"', $exception->getMessage()),
41
            0,
42
            $exception
43
        );
44
    }
45
}
46