Completed
Pull Request — master (#580)
by Greg
03:16
created

CollectionTestTask   A

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