Frame::newLine()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpSchool\CliMenu;
4
5
/**
6
 * Represents the current screen being displayed
7
 * contains all rows of output
8
 *
9
 * @author Aydin Hassan <[email protected]>
10
 */
11
class Frame implements \Countable
12
{
13
    /**
14
     * @var array
15
     */
16
    private $rows = [];
17
18
    public function newLine(int $count = 1) : void
19
    {
20
        foreach (range(1, $count) as $i) {
21
            $this->rows[] = "\n";
22
        }
23
    }
24
25
    public function addRows(array $rows = []) : void
26
    {
27
        foreach ($rows as $row) {
28
            $this->rows[] = $row;
29
        }
30
    }
31
32
    public function addRow(string $row) : void
33
    {
34
        $this->rows[] = $row;
35
    }
36
37
    public function count() : int
38
    {
39
        return count($this->rows);
40
    }
41
42
    public function getRows() : array
43
    {
44
        return $this->rows;
45
    }
46
}
47