Completed
Push — master ( 1e2def...61d955 )
by Omar
02:27
created

CsvOutput::writeDiffItem()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 52
Code Lines 26

Duplication

Lines 27
Ratio 51.92 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 27
loc 52
rs 9.4929
cc 3
eloc 26
nc 4
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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