Completed
Push — master ( d7f072...e80481 )
by Shcherbak
05:37
created

Report::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
  namespace Funivan\Cs\Report;
4
5
  use Funivan\Cs\FileFinder\File;
6
  use Funivan\Cs\FileTool\FileTool;
7
8
  /**
9
   * @author Ivan Shcherbak <[email protected]> 2016
10
   */
11
  class Report implements \IteratorAggregate, \Countable {
12
13
    /**
14
     * @var Message[]
15
     */
16
    private $messages = [];
17
18
19
20
21
    /**
22
     * @param File $file
23
     * @param FileTool $tool
24
     * @param string $message
25
     * @param int|null $line
26
     * @return $this
27
     */
28 18
    public function addMessage(File $file, FileTool $tool, $message, $line = null) {
29 18
      $this->messages[] = new Message($file, $tool, $message, $line);
30 18
      return $this;
31
    }
32
33
34
    /**
35
     * @return Message[]
36
     */
37 10
    public function getIterator() {
38 10
      return new \ArrayIterator($this->messages);
39
    }
40
41
42
    /**
43
     * Count elements of an object
44
     * @link http://php.net/manual/en/countable.count.php
45
     * @return int The custom count as an integer.
46
     * </p>
47
     * <p>
48
     * The return value is cast to an integer.
49
     * @since 5.1.0
50
     */
51
    public function count() {
52
      return count($this->messages);
53
    }
54
55
  }