DataMapperDecorator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A read() 0 4 1
A write() 0 4 1
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