AbstractContainer::dump()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the PhpM3u8 package.
5
 *
6
 * (c) Chrisyue <http://chrisyue.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Chrisyue\PhpM3u8;
13
14
abstract class AbstractContainer implements DumpableInterface
15
{
16 1
    public function readLines(array &$lines)
17
    {
18 1
        foreach ($this->getComponents() as $component) {
19 1
            if (empty($lines)) {
20 1
                break;
21
            }
22
23 1
            $component->readLines($lines);
24 1
        }
25 1
    }
26
27
    public function dump()
28
    {
29 1
        $lines = array_map(function (DumpableInterface $dumper) {
30 1
            return $dumper->dump();
31 1
        }, $this->getComponents());
32
33 1
        return implode("\n", array_filter($lines));
34
    }
35
36
    abstract protected function getComponents();
37
}
38