CsvOutput   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 53
ccs 18
cts 18
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A write() 0 14 3
A writeHeader() 0 4 1
A writeDifferenceSet() 0 10 2
1
<?php
2
3
namespace TemplesOfCode\CodeSanity\Output;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use TemplesOfCode\CodeSanity\Output;
7
use TemplesOfCode\CodeSanity\DiffItem;
8
9
/**
10
 * Class CsvOutput
11
 * @package TemplesOfCode\CodeSanity\Output
12
 */
13
class CsvOutput extends Output
14
{
15
16
    protected $mask = '%s,%s,%s,%s';
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 3
    protected function init()
22
    {
23
24 3
    }
25
26
    /**
27
     *
28
     */
29 2
    public function write()
30
    {
31 2
        if ($this->headerEnabled) {
32 2
            $this->writeHeader();
33 2
        }
34
35 2
        foreach ($this->differences as $differenceSet) {
36
            /**
37
             * @var ArrayCollection $differenceSet
38
             */
39
40 2
            $this->writeDifferenceSet($differenceSet);
41 2
        }
42 2
    }
43
44
    /**
45
     *
46
     */
47 2
    private function writeHeader()
48
    {
49 2
        $this->output->writeln(implode(',', self::$header));
50 2
    }
51
52
    /**
53
     * @param ArrayCollection $differenceSet
54
     */
55 2
    private function writeDifferenceSet(ArrayCollection $differenceSet)
56
    {
57 2
        foreach ($differenceSet as $diffItem) {
58
            /**
59
             * @var DiffItem $diffItem
60
             */
61
62 2
            $this->writeDiffItem($diffItem);
63 2
        }
64 2
    }
65
}
66