CsvOutput   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A result() 0 24 4
1
<?php
2
namespace Finder\Logic\Output;
3
4
use League\Csv\Writer;
5
use Finder\Logic\AnalysisResult;
6
7
class CsvOutput extends AbstractOutput
8
{
9
    /**
10
     * @inheritdoc
11
     */
12
    public function result(AnalysisResult $result)
13
    {
14
        $writer = Writer::createFromString('');
15
        $writer->insertOne(['File', 'Line', 'Tool', 'Type', 'Message']);
16
17
        foreach ($result->toArray() as $fileName => $lines) {
18
            foreach ($lines as $lineNumber => $issues) {
19
                foreach ($issues as $issue) {
20
                    $writer->insertOne(
21
                        [
22
                        $fileName,
23
                        $lineNumber,
24
                        $issue['tool'],
25
                        $issue['type'],
26
                        trim($issue['message']),
27
                        ]
28
                    );
29
                }
30
            }
31
        }
32
33
        $csv = ltrim($writer->__toString());
0 ignored issues
show
Deprecated Code introduced by
The method League\Csv\AbstractCsv::__toString() has been deprecated with message: deprecated since version 9.1.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
34
        $this->cli->out($csv);
35
    }
36
}
37