Completed
Push — master ( e3a6ad...a80db0 )
by Krishnaprasad
04:55
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
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