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

Report   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 45
wmc 3
lcom 1
cbo 1
ccs 5
cts 7
cp 0.7143
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addMessage() 0 4 1
A getIterator() 0 3 1
A count() 0 3 1
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
  }