TaskInfo::getTaskContext()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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