Passed
Push — master ( 9e5fe0...88d9d6 )
by Tom
04:35
created

FileTable::addRow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\Utility\Show;
6
7
class FileTable
8
{
9
    /**
10
     * @var int
11
     */
12
    private $errors = 0;
13
14
    /**
15
     * @var array
16
     */
17
    private $table;
18
19 14
    public function __construct(array $firstRow)
20
    {
21 14
        $this->addRow($firstRow);
22 14
    }
23
24
    /**
25
     * @param array $row
26
     *
27
     * @return $this
28
     */
29 14
    public function addRow(array $row)
30
    {
31 14
        $this->table[] = $row;
32
33 14
        return $this;
34
    }
35
36
    /**
37
     * @param mixed $falsyIsError
38
     * @param array $row
39
     *
40
     * @return $this
41
     */
42 9
    public function addFlaggedRow($falsyIsError, array $row)
43
    {
44 9
        if (!$falsyIsError) {
45 8
            $this->errors++;
46
        }
47
48 9
        return $this->addRow($row);
49
    }
50
51
    /**
52
     * @param array $row
53
     *
54
     * @return $this
55
     */
56 8
    public function addErrorRow(array $row)
57
    {
58 8
        return $this->addFlaggedRow(false, $row);
59
    }
60
61
    /**
62
     * @return int
63
     */
64 13
    public function getErrors()
65
    {
66 13
        return $this->errors;
67
    }
68
69
    /**
70
     * @return array
71
     */
72 13
    public function toArray()
73
    {
74 13
        return $this->table;
75
    }
76
}
77