Completed
Pull Request — master (#15)
by Martin
13:18
created

DirectoryResource   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getIterator() 0 6 2
1
<?php
2
3
namespace Goetas\TwitalBundle\Assetic\Factory;
4
5
use Assetic\Factory\Resource\DirectoryResource as BaseDirectoryResource;
6
use Symfony\Component\Templating\Loader\LoaderInterface;
7
8
class DirectoryResource extends BaseDirectoryResource
9
{
10
    protected $loader;
11
12
    protected $path;
13
14
    /**
15
     * @param LoaderInterface $loader The templating loader
16
     * @param string $path The directory path
17
     * @param string $pattern A regex pattern for file basenames
18
     */
19
    public function __construct(LoaderInterface $loader, $path, $pattern = null)
20
    {
21
        $this->loader = $loader;
22
        $this->path = rtrim($path, '/') . '/';
23
24
        parent::__construct($path, $pattern);
25
    }
26
27
    public function getIterator()
28
    {
29
        return is_dir($this->path)
30
            ? new DirectoryResourceIterator($this->loader, $this->path, $this->getInnerIterator())
31
            : new \EmptyIterator();
32
    }
33
}
34