Completed
Push — master ( 2eec4d...df0d5e )
by Tomáš
03:19
created

CodeSnifferStyle::newLine()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\PHP7_CodeSniffer\Console\Style;
9
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
use Symfony\Component\Console\Style\SymfonyStyle;
13
14
final class CodeSnifferStyle
15
{
16
    /**
17
     * @var SymfonyStyle
18
     */
19
    private $symfonyStyle;
20
21 7
    public function __construct(InputInterface $input, OutputInterface $output)
22
    {
23 7
        $this->symfonyStyle = new SymfonyStyle($input, $output);
24 7
    }
25
26 3
    public function success(string $message)
27
    {
28 3
        $this->symfonyStyle->success($message);
29 3
    }
30
31 4
    public function error(string $message)
32
    {
33 4
        $this->symfonyStyle->error($message);
34 4
    }
35
36 5
    public function writeErrorReports(array $errorReports)
37
    {
38 5
        foreach ($errorReports as $file => $errors) {
39 4
            $this->symfonyStyle->section('FILE: ' . $file);
40
41 4
            $tableRows = $this->formatErrorsToTableRows($errors);
42 4
            $this->symfonyStyle->table(['Line', 'Error', 'Sniff Code', 'Fixable'], $tableRows);
43
44 4
            $this->symfonyStyle->newLine();
45
        }
46 5
    }
47
48 4
    private function formatErrorsToTableRows(array $errors) : array
49
    {
50 4
        foreach ($errors as $key => $error) {
51 4
            $errors[$key]['isFixable'] = $error['isFixable'] ? 'YES' : 'No';
52
        }
53
54 4
        return $errors;
55
    }
56
}
57