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

ConsoleTableExporter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 24
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A export() 0 11 2
A getName() 0 3 1
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