Test Failed
Push — main ( d2d042...ea42f2 )
by Bingo
13:21
created

MetricsUtil   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
eloc 23
c 1
b 0
f 0
dl 0
loc 49
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolveInternalName() 0 16 5
A resolvePublicName() 0 16 5
1
<?php
2
3
namespace Jabe\Engine\Impl\Metrics\Util;
4
5
use Jabe\Engine\Management\Metrics;
6
7
class MetricsUtil
8
{
9
    /**
10
     * Resolves the internal name of the metric by the public name.
11
     *
12
     * @param publicName the public name
13
     * @return string the internal name
14
     */
15
    public static function resolveInternalName(?string $publicName): ?string
16
    {
17
        if ($publicName == null) {
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $publicName of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
18
            return null;
19
        }
20
        switch ($publicName) {
21
            case Metrics::TASK_USERS:
0 ignored issues
show
Bug introduced by
The constant Jabe\Engine\Management\Metrics::TASK_USERS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
22
                return Metrics::UNIQUE_TASK_WORKERS;
23
            case Metrics::PROCESS_INSTANCES:
0 ignored issues
show
Bug introduced by
The constant Jabe\Engine\Management\Metrics::PROCESS_INSTANCES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
24
                return Metrics::ROOT_PROCESS_INSTANCE_START;
25
            //case Metrics::DECISION_INSTANCES:
26
            //    return Metrics::EXECUTED_DECISION_INSTANCES;
27
            case Metrics::FLOW_NODE_INSTANCES:
0 ignored issues
show
Bug introduced by
The constant Jabe\Engine\Management\M...cs::FLOW_NODE_INSTANCES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
28
                return Metrics::ACTIVTY_INSTANCE_START;
29
            default:
30
                return $publicName;
31
        }
32
    }
33
34
    /**
35
     * Resolves the public name of the metric by the internal name.
36
     *
37
     * @param internalName the internal name
38
     * @return string the public name
39
     */
40
    public static function resolvePublicName(?string $internalName): ?string
41
    {
42
        if ($internalName == null) {
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $internalName of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
43
            return null;
44
        }
45
        switch ($internalName) {
46
            case Metrics::UNIQUE_TASK_WORKERS:
47
                return Metrics::TASK_USERS;
0 ignored issues
show
Bug introduced by
The constant Jabe\Engine\Management\Metrics::TASK_USERS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
48
            case Metrics::ROOT_PROCESS_INSTANCE_START:
49
                return Metrics::PROCESS_INSTANCES;
0 ignored issues
show
Bug introduced by
The constant Jabe\Engine\Management\Metrics::PROCESS_INSTANCES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
50
            //case Metrics::EXECUTED_DECISION_INSTANCES:
51
            //    return Metrics::DECISION_INSTANCES;
52
            case Metrics::ACTIVTY_INSTANCE_START:
53
                return Metrics::FLOW_NODE_INSTANCES;
0 ignored issues
show
Bug introduced by
The constant Jabe\Engine\Management\M...cs::FLOW_NODE_INSTANCES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
54
            default:
55
                return $internalName;
56
        }
57
    }
58
}
59