GetThemesFromDir   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 4
c 2
b 1
f 1
lcom 0
cbo 0
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 18 4
1
<?php
2
3
/**
4
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
 *
16
 * This software consists of voluntary contributions made by many individuals
17
 * and is licensed under the MIT license.
18
 */
19
namespace LearnZF2Themes\Factory;
20
21
use DirectoryIterator;
22
23
/**
24
 * @author Stanimir Dimitrov <[email protected]>
25
 */
26
final class GetThemesFromDir
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function __invoke()
32
    {
33
        $path = __DIR__.'/../../../themes/';
34
        $dir = new DirectoryIterator($path);
35
        $themesConfig = [];
36
37
        foreach ($dir as $file) {
38
            if (!$file->isDot()) {
39
                $hasConfig = $path.$file->getBasename().'/config/module.config.php';
40
41
                if (is_file($hasConfig)) {
42
                    $themesConfig['themes'][$file->getBasename()] = include $hasConfig;
43
                }
44
            }
45
        }
46
47
        return $themesConfig;
48
    }
49
}
50