Completed
Pull Request — master (#32)
by Krishnaprasad
04:30
created

ClamavValidatorException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 22.22%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 39
ccs 4
cts 18
cp 0.2222
rs 10
c 0
b 0
f 0

3 Methods

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