Passed
Push — 3.0 ( 58bd2d...2f6977 )
by Vermeulen
01:15
created

ReadDirLoadModule   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A itemAction() 0 17 3
A dirAction() 0 7 2
1
<?php
2
3
namespace BFW\Install;
4
5
use bultonFr\Utils\Files\ReadDirectory;
6
7
/**
8
 * Class use to detect modules in a directory and sub-directories
9
 */
10
class ReadDirLoadModule extends ReadDirectory
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    protected function itemAction(string $fileName, string $pathToFile): string
16
    {
17
        //Call parent method to check ignored files
18
        $parentAction = parent::itemAction($fileName, $pathToFile);
19
20
        if (!empty($parentAction)) {
21
            return $parentAction;
22
        }
23
24
        //Detect the file containing module infos
25
        if ($fileName === 'bfwModulesInfos.json') {
26
            $this->list[] = $pathToFile;
27
28
            return 'break';
29
        }
30
31
        return '';
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    protected function dirAction(string $dirPath)
38
    {
39
        if (preg_match('/test(s?)$/', $dirPath) === 1) {
40
            return;
41
        }
42
43
        return parent::dirAction($dirPath);
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::dirAction($dirPath) targeting bultonFr\Utils\Files\ReadDirectory::dirAction() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
44
    }
45
}
46