GraphicalTestCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 6
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\Warehouse;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Helper\Table;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class GraphicalTestCommand extends Command
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    protected function configure()
18
    {
19
        $this
20
            ->setName('ggggino:warehouse:print-matrix')
21
            ->setDescription('Print a beautiful matrix')
22
            ->setHelp(<<<EOT
23
Print a beautiful matrix.
24
EOT
25
            );
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $warehouse = Warehouse::createFromJson(getcwd() . "/resources/biggerWarehouse.json");
34
35
        /** @var Place $nodeStart */
36
        $nodeStart = $warehouse->getPlacesCollector()->getPlaces()[5];
37
        /** @var Place $nodeEnd */
38
        $nodeEnd = $warehouse->getPlacesCollector()->getPlaces()[30];
39
40
        $warehouse->getPath($nodeStart, $nodeEnd);
41
42
        $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

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