AbstractLoader::validatePath()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Assimtech\Tempo\Loader;
4
5
use RuntimeException;
6
7
abstract class AbstractLoader
8
{
9
    /**
10
     * @param string $path
11
     * @throws \RuntimeException
12
     */
13 7
    protected function validatePath($path)
14
    {
15 7
        if (!is_string($path)) {
16 2
            throw new RuntimeException(sprintf(
17 2
                '$path must be a string (%s given)',
18 2
                gettype($path)
19 2
            ));
20
        }
21
22 5
        if (!file_exists($path)) {
23 2
            throw new RuntimeException(sprintf(
24 2
                'File not found: %s',
25
                $path
26 2
            ));
27
        }
28 3
    }
29
30
    /**
31
     * @param string $path
32
     * @return mixed
33
     */
34
    abstract public function load($path);
35
}
36