PathExpander   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A expand() 0 12 2
1
<?php
2
3
namespace Knp\RadBundle\Filesystem;
4
5
use Symfony\Component\HttpKernel\KernelInterface;
6
7
class PathExpander
8
{
9
    private $kernel;
10
11
    public function __construct(KernelInterface $kernel)
12
    {
13
        $this->kernel = $kernel;
14
    }
15
16
    /**
17
     * Expands the given path if needed (i.e bundle resource path)
18
     *
19
     * @param string $path The path to expand
20
     *
21
     * @return string The expanded path
22
     */
23
    public function expand($path)
24
    {
25
        if (0 !== strpos($path, '@')) {
26
            return $path;
27
        }
28
29
        list($bundleName, $relPath) = explode('/', substr($path, 1), 2);
30
31
        $bundle = $this->kernel->getBundle($bundleName);
32
33
        return sprintf('%s/%s', $bundle->getPath(), $relPath);
34
    }
35
}
36