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(); |
|
|
|
|
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
|
|
|
|