CsvOutput::result()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 1
dl 0
loc 24
rs 9.536
c 0
b 0
f 0
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