TaskInfo   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 28.13 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 9
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTaskContext() 0 7 1
A formatTaskName() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Robo;
4
5
class TaskInfo
6
{
7
    /**
8
     * Return a context useful for logging messages.
9
     *
10
     * @param object $task
11
     *
12
     * @return array
13
     */
14
    public static function getTaskContext($task)
15
    {
16
        return [
17
            'name' => TaskInfo::formatTaskName($task),
18
            'task' => $task,
19
        ];
20
    }
21
22
    /**
23
     * @param object $task
24
     *
25
     * @return string
26
     */
27 View Code Duplication
    public static function formatTaskName($task)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
    {
29
        $name = get_class($task);
30
        $name = preg_replace('~Stack^~', '', $name);
31
        $name = str_replace('Robo\\Task\Base\\', '', $name);
32
        $name = str_replace('Robo\\Task\\', '', $name);
33
        $name = str_replace('Robo\\Collection\\', '', $name);
34
        return $name;
35
    }
36
}
37