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

SinglePage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 17
ccs 9
cts 9
cp 1
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A unpack() 0 3 1
A pack() 0 10 4
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