CsvNormaliser   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 4
Dependencies 4

Test Coverage

Coverage 75%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 8
c 2
b 0
f 0
lcom 4
cbo 4
dl 0
loc 70
ccs 12
cts 16
cp 0.75
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A serialiser() 0 8 2
A unserialiser() 0 8 2
A writer() 0 8 2
A reader() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of Payload.
5
 *
6
 * (c) DraperStudio <[email protected]>
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 DraperStudio\Payload\Normalisers;
13
14
use DraperStudio\Payload\Contracts\Normaliser;
15
use DraperStudio\Payload\Readers\CsvReader;
16
use DraperStudio\Payload\Serialisers\CsvSerialiser;
17
use DraperStudio\Payload\Unserialisers\CsvUnserialiser;
18
use DraperStudio\Payload\Writers\CsvWriter;
19
20
/**
21
 * Class CsvNormaliser.
22
 */
23
class CsvNormaliser implements Normaliser
24
{
25
    /**
26
     * @var
27
     */
28
    protected $serialiser;
29
30
    /**
31
     * @var
32
     */
33
    protected $unserialiser;
34
35
    /**
36
     * @var
37
     */
38
    protected $writer;
39
40
    /**
41
     * @var
42
     */
43
    protected $reader;
44
45
    /**
46
     * @return CsvSerialiser
47
     */
48 3
    public function serialiser()
49
    {
50 3
        if ($this->serialiser) {
51
            return $this->serialiser;
52
        }
53
54 3
        return $this->serialiser = new CsvSerialiser();
55
    }
56
57
    /**
58
     * @return CsvUnserialiser
59
     */
60 3
    public function unserialiser()
61
    {
62 3
        if ($this->unserialiser) {
63
            return $this->unserialiser;
64
        }
65
66 3
        return $this->unserialiser = new CsvUnserialiser();
67
    }
68
69
    /**
70
     * @return CsvWriter
71
     */
72 3
    public function writer()
73
    {
74 3
        if ($this->writer) {
75
            return $this->writer;
76
        }
77
78 3
        return $this->writer = new CsvWriter();
79
    }
80
81
    /**
82
     * @return CsvReader
83
     */
84 3
    public function reader()
85
    {
86 3
        if ($this->reader) {
87
            return $this->reader;
88
        }
89
90 3
        return $this->reader = new CsvReader();
91
    }
92
}
93