ResultCollection::addResult()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace N98\Magento\Command\System\Check;
4
5
use Traversable;
6
7
/**
8
 * Class ResultCollection
9
 *
10
 * @package N98\Magento\Command\System\Check
11
 */
12
class ResultCollection implements \IteratorAggregate
13
{
14
    /**
15
     * @var array
16
     */
17
    protected $_results;
18
19
    /**
20
     * @var string
21
     */
22
    protected $_resultGroup;
23
24
    /**
25
     * @param Result $result
26
     * @return $this
27
     */
28
    public function addResult(Result $result)
29
    {
30
        $this->_results[] = $result;
31
32
        return $this;
33
    }
34
35
    /**
36
     * @param string $status
37
     * @param string $message
38
     * @return Result
39
     */
40
    public function createResult($status = Result::STATUS_OK, $message = '')
41
    {
42
        $result = new Result($status, $message);
43
        $result->setResultGroup($this->_resultGroup);
44
        $this->addResult($result);
45
46
        return $result;
47
    }
48
49
    /**
50
     * @param string $resultGroup
51
     */
52
    public function setResultGroup($resultGroup)
53
    {
54
        $this->_resultGroup = $resultGroup;
55
    }
56
57
    /**
58
     * @return Traversable An instance of an object implementing <b>Iterator</b> or
59
     */
60
    public function getIterator()
61
    {
62
        return new \ArrayObject($this->_results);
63
    }
64
}
65