CollectionTestTask::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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