FilesystemThemeProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 45
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getThemeList() 0 19 4
1
<?php
2
3
namespace Neirda\Bundle\LiipThemeProvider\Provider;
4
5
use Neirda\Bundle\LiipThemeProvider\Theme\ThemeProviderInterface;
6
use Symfony\Component\Finder\Finder;
7
use Symfony\Component\Finder\SplFileInfo;
8
9
class FilesystemThemeProvider implements ThemeProviderInterface
10
{
11
    /**
12
     * @var null|array
13
     */
14
    protected $themeList = null;
15
16
    /**
17
     * @var array
18
     */
19
    protected $paths = array();
20
21
    /**
22
     * Constructor.
23
     *
24
     * @param array $paths
25
     */
26
    public function __construct(array $paths = array())
27
    {
28
        $this->paths = $paths;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function getThemeList()
35
    {
36
        if (!is_array($this->themeList)) {
37
            $themeList = array();
38
            foreach ($this->paths as $path) {
39
                $path   = rtrim($path, DIRECTORY_SEPARATOR);
40
                $themes = new Finder();
41
                $themes->directories()->depth('== 0')->in($path);
42
                foreach ($themes as $theme) {
43
                    /** @var SplFileInfo $theme */
44
                    $themeList[] = $theme->getFilename();
45
                }
46
            }
47
48
            $this->themeList = $themeList;
49
        }
50
51
        return $this->themeList;
52
    }
53
}
54