FileExistsCheck   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 3 1
A run() 0 6 2
A getIdentifier() 0 3 1
1
<?php
2
3
namespace Leankoala\HealthFoundation\Check\Files;
4
5
use Leankoala\HealthFoundation\Check\Check;
6
use Leankoala\HealthFoundation\Check\Result;
7
8
9
/**
10
 * Class FileExistsCheck
11
 *
12
 * This class checks if a given file exists
13
 *
14
 * @package Leankoala\HealthFoundation\Check\Files
15
 */
16
class FileExistsCheck implements Check
17
{
18
    const IDENTIFIER = 'base:files:fileExists';
19
20
    private $filename;
21
22
    public function run()
23
    {
24
        if (file_exists($this->filename)) {
25
            return new Result(Result::STATUS_PASS, 'The file "' . $this->filename . '" exists.');
26
        }else{
27
            return new Result(Result::STATUS_FAIL, 'The file "' . $this->filename . '" does not exist.');
28
        }
29
    }
30
31
    /**
32
     * @param $filename
33
     */
34
    public function init($filename)
35
    {
36
        $this->filename = $filename;
37
    }
38
39
    public function getIdentifier()
40
    {
41
        return self::IDENTIFIER;
42
    }
43
}
44