Passed
Push — master ( a7fcca...216d44 )
by Mike
02:49
created

FileCheckerTrait::configurationFileExists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 10
1
<?php
2
3
namespace Mediadevs\Configuration\Traits;
4
5
use Mediadevs\Configuration\Exceptions\ConfigurationFileException;
6
7
trait FileCheckerTrait
8
{
9
    /**
10
     * Whether the configuration file exists.
11
     *
12
     * @param string $file
13
     *
14
     * @throws ConfigurationFileException
15
     *
16
     * @return bool
17
     */
18 2
    public function configurationFileExists(string $file): bool
19
    {
20
        // An exception will be thrown if the file doesn't exist
21 2
        if (file_exists($file)) {
22 2
            return true;
23
        } else {
24
            throw new ConfigurationFileException();
25
        }
26
    }
27
}
28