Passed
Push — develop ( c63c86...961153 )
by Guillaume
01:51
created

BaseWorkflow::getMenuClassName()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 6
rs 10
1
<?php
2
3
namespace App\Workflow;
4
5
abstract class BaseWorkflow implements Workflow
0 ignored issues
show
Bug introduced by
The type App\Workflow\Workflow was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
{
7
    private static $instance = null;
8
    private $scriptFilter = null;
9
10
11
    final protected function __construct()
12
    {
13
        $this->scriptFilter = ScriptFilter::create();
0 ignored issues
show
Bug introduced by
The type App\Workflow\ScriptFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
    }
15
16
    final public static function getInstance()
17
    {
18
        if (is_null(self::$instance)) {
19
            self::$instance = new self;
20
        }
21
22
        return self::$instance;
23
    }
24
25
    public static function currentMenu()
26
    {
27
        self::getCurrentMenuClass()::scriptFilter();
28
29
        return self::getInstance()->scriptFilter->output();
30
    }
31
32
    private static function getCurrentMenuClass()
33
    {
34
        $args = explode('_', getenv('action'));
0 ignored issues
show
Unused Code introduced by
The assignment to $args is dead and can be removed.
Loading history...
35
36
        return __NAMESPACE__ . "\\Menus\\" . (self::getMenuClassName(getenv('action')) ?: 'Entrance');
37
    }
38
39
    private static function getMenuClassName($action)
40
    {
41
        return str_replace('_', '', ucwords($action === false ? 'entrance' : $action, '_'));
42
    }
43
44
    final public static function destroy()
45
    {
46
        ScriptFilter::destroy();
47
48
        self::$instance = null;
49
    }
50
51
    final private function __clone()
52
    {
53
    }
54
55
    abstract public static function do();
56
57
    abstract public static function notify($result = false);
58
}
59