DataMapperDecorator::read()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Balloon\Mapper;
3
4
use Balloon\Reader\IFileReader;
5
6
/**
7
 * Class DataMapperDecorator
8
 * @package Balloon\Mapper
9
 * @author Raphaël Lefebvre <[email protected]>
10
 */
11
class DataMapperDecorator implements IFileReader
12
{
13
    /**
14
     * @var IFileReader
15
     */
16
    private $fileReader;
17
18
    /**
19
     * @var DataMapper
20
     */
21
    private $dataMapper;
22
23
    /**
24
     * @param IFileReader $fileReader
25
     * @param DataMapper $dataMapper
26
     */
27
    public function __construct(IFileReader $fileReader, DataMapper $dataMapper)
28
    {
29
        $this->fileReader = $fileReader;
30
        $this->dataMapper = $dataMapper;
31
    }
32
33
    /**
34
     * @return array
0 ignored issues
show
Documentation introduced by
Should the return type not be \ArrayObject?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
35
     */
36
    public function read()
37
    {
38
        return $this->dataMapper->mapDataList((array)$this->fileReader->read());
39
    }
40
41
    /**
42
     * @param array $data
43
     * @param int $mode
44
     * @return int
45
     */
46
    public function write($data, $mode = 0)
47
    {
48
        return $this->fileReader->write($this->dataMapper->unmapObjects((array)$data), $mode);
49
    }
50
}
51