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

CollectionTestTask::parenthesizer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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