Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
43 | 6 | public static function load($file) |
|
44 | { |
||
45 | 6 | if (!File::isFile($file)) |
|
46 | { |
||
47 | 1 | throw new NotFound\Path($file); |
|
48 | } |
||
49 | |||
50 | 5 | if (!File::isReadable($file)) |
|
51 | { |
||
52 | 1 | throw new Exceptions\PermissionDenied($file); |
|
53 | } |
||
54 | |||
55 | 4 | $preg = PregMatch::first('~\.(?<ext>\w+)$~', $file); |
|
56 | |||
57 | 4 | $class = Arr::get( |
|
58 | 4 | static::$extensions, |
|
59 | 4 | Arr::get($preg->matches, 'ext', 'php'), |
|
|
|||
60 | 4 | static::$extensions['php'] |
|
61 | ); |
||
62 | |||
63 | 4 | return new $class($file); |
|
64 | } |
||
67 |