Passed
Push — master ( 724c6f...9da6fd )
by Rafael
06:22
created

ConsoleTableExporter::export()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
crap 6
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Error\Exporter;
12
13
use Symfony\Component\Console\Helper\Table;
14
use Symfony\Component\Console\Output\OutputInterface;
15
16
class ConsoleTableExporter implements ErrorListExporterInterface
17
{
18
    /**
19
     * {@inheritDoc}
20
     */
21
    public function getName(): string
22
    {
23
        return 'console';
24
    }
25
26
    /**
27
     * @inheritDoc
28
     */
29
    public function export($errors, OutputInterface $output): void
30
    {
31
        $rows = [];
32
        foreach ($errors as $error) {
33
            $rows[] = [$error->getCode(), $error->getMessage(), $error->getDescription()];
34
        }
35
36
        $table = new Table($output);
37
        $table->setHeaders(['Code', 'Text', 'Description'])
38
              ->setRows($rows);
39
        $table->render();
40
    }
41
}
42