Passed
Push — master ( c85748...2fd0ab )
by Petr
08:11
created

SinglePage::pack()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 6
c 1
b 0
f 1
nc 3
nop 1
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 4
rs 10
1
<?php
2
3
namespace kalanis\kw_mapper\Storage\Shared\FormatFiles;
4
5
6
use kalanis\kw_mapper\Interfaces\IFileFormat;
7
use kalanis\kw_mapper\MapperException;
8
9
10
/**
11
 * Class SinglePage
12
 * @package kalanis\kw_mapper\Storage\Shared\FormatFiles
13
 */
14
class SinglePage implements IFileFormat
15
{
16 6
    public function unpack(string $content): array
17
    {
18 6
        return [[$content]];
19
    }
20
21 7
    public function pack(array $records): string
22
    {
23 7
        $line = reset($records);
24 7
        if (false !== $line && is_array($line)) {
25 6
            $content = reset($line);
26 6
            if (false !== $content) {
27 6
                return strval($content);
28
            }
29
        }
30 1
        throw new MapperException('Cannot pack single page into data stream');
31
    }
32
}
33