FileExistsCheck::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 6
rs 10
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