CollectionTestTask   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 41
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A run() 0 4 1
A getValue() 0 7 1
A parenthesizer() 0 5 1
A emphasizer() 0 5 1
1
<?php
2
namespace Robo\Task;
3
4
use Robo\Result;
5
use Robo\Task\BaseTask;
6
use Robo\Collection\Collection;
7
8
class CollectionTestTask extends BaseTask
9
{
10
    protected $key;
11
    protected $value;
12
13
    public function __construct($key, $value)
14
    {
15
        $this->key = $key;
16
        $this->value = $value;
17
    }
18
19
    public function run()
20
    {
21
        return $this->getValue();
22
    }
23
24
    protected function getValue()
25
    {
26
        $result = Result::success($this);
27
        $result[$this->key] = $this->value;
28
29
        return $result;
30
    }
31
32
    // Note that by returning a value with the same
33
    // key as the result, we overwrite the value generated
34
    // by the primary task method ('run()').  If we returned
35
    // a result with a different key, then both values
36
    // would appear in the result.
37
    public function parenthesizer()
38
    {
39
        $this->value = "({$this->value})";
40
        return $this->getValue();
41
    }
42
43
    public function emphasizer()
44
    {
45
        $this->value = "*{$this->value}*";
46
        return $this->getValue();
47
    }
48
}
49
50