Passed
Push — master ( 4f8f39...eb7dd8 )
by David
01:55
created

GraphicalTestCommand::getMatrixSimple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace GGGGino\WarehousePath\Tools\Console\Command;
4
5
use GGGGino\WarehousePath\Entity\Place;
6
use GGGGino\WarehousePath\JsonReader;
7
use GGGGino\WarehousePath\Warehouse;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Helper\Table;
10
use Symfony\Component\Console\Input\InputArgument;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use WarehouseMatrixTest;
14
15
class GraphicalTestCommand extends Command
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected function configure()
21
    {
22
        $this
23
            ->setName('ggggino:warehouse:print-matrix')
24
            ->setDescription('Print a beautiful matrix')
25
            ->setHelp(<<<EOT
26
Print a beautiful matrix.
27
EOT
28
            );
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $warehouse = Warehouse::createFromJson(getcwd() . "/resources/biggerWarehouse.json");
37
38
        /** @var Place $nodeStart */
39
        $nodeStart = $warehouse->getPlaces()[5];
40
        /** @var Place $nodeEnd */
41
        $nodeEnd = $warehouse->getPlaces()[30];
42
43
        $warehouse->getPath($nodeStart, $nodeEnd);
44
45
        $calculatedMatrix = $warehouse->getParser()->getCalculatedMatrix();
0 ignored issues
show
Bug introduced by
The method getCalculatedMatrix() does not exist on GGGGino\WarehousePath\Parser\ParserInterface. It seems like you code against a sub-type of GGGGino\WarehousePath\Parser\ParserInterface such as GGGGino\WarehousePath\Parser\MatrixParser. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
        $calculatedMatrix = $warehouse->getParser()->/** @scrutinizer ignore-call */ getCalculatedMatrix();
Loading history...
46
47
        $table = new Table($output);
48
        $table->setRows($calculatedMatrix);
49
        $table->render();
50
51
        $output->writeln("Start: " . $nodeStart->getName());
52
        $output->writeln("End: " . $nodeEnd->getName());
53
        $output->writeln("Total path: " . $nodeEnd->getCurrentWeight());
54
    }
55
}
56