Completed
Push — extensions ( 84a6ae )
by
unknown
22:00 queued 07:01
created

PathExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B register() 0 26 6
1
<?php
2
3
namespace League\Plates\Extension\Path;
4
5
use League\Plates;
6
7
final class PathExtension implements Plates\Extension
8
{
9
    public function register(Plates\Engine $plates) {
10
        $c = $plates->getContainer();
11
        $c->add('path.resolvePath.stack', function($c) {
12
            $config = $c->get('config');
13
14
            // wrap base dir in an array if not already
15
            $base_dir = isset($config['base_dir']) ? $config['base_dir'] : null;
16
            $base_dir = $base_dir ? (is_string($base_dir) ? [$base_dir] : $base_dir) : $base_dir;
17
18
            return array_filter([
19
                'relative' =>relativeResolvePath(),
20
                'ext' => isset($config['ext']) ? extResolvePath($config['ext']) : null,
21
                'prefix' => $base_dir ? prefixResolvePath($base_dir, $c->get('fileExists')) : null,
22
                'id' => idResolvePath(),
23
            ]);
24
        });
25
        $c->add('path.resolvePath', function($c) {
26
            return Plates\Util\stack($c->get('path.resolvePath.stack'));
27
        });
28
        $c->wrap('compose', function($compose, $c) {
29
            return Plates\Util\compose(
30
                $compose,
31
                resolvePathCompose($c->get('path.resolvePath'))
32
            );
33
        });
34
    }
35
}
36