1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GGGGino\WarehousePath\Tools\Console\Command; |
4
|
|
|
|
5
|
|
|
use GGGGino\WarehousePath\Calculator\FastCalculator; |
6
|
|
|
use GGGGino\WarehousePath\Calculator\ShortPathCalculator; |
7
|
|
|
use GGGGino\WarehousePath\Entity\Place; |
8
|
|
|
use GGGGino\WarehousePath\JsonReader; |
9
|
|
|
use GGGGino\WarehousePath\Warehouse; |
10
|
|
|
use GGGGino\WarehousePath\WarehouseTree; |
|
|
|
|
11
|
|
|
use Symfony\Component\Console\Command\Command; |
12
|
|
|
use Symfony\Component\Console\Helper\Table; |
13
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
16
|
|
|
use WarehouseMatrixTest; |
17
|
|
|
|
18
|
|
|
class ShortestPathGraphicalTestCommand extends Command |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
*/ |
23
|
|
|
protected function configure() |
24
|
|
|
{ |
25
|
|
|
$this |
26
|
|
|
->setName('ggggino:warehouse:spg-print-matrix') |
27
|
|
|
->setDescription('Print a beautiful matrix with the shortest path') |
28
|
|
|
->setHelp(<<<EOT |
29
|
|
|
Print a beautiful matrix. |
30
|
|
|
EOT |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
38
|
|
|
{ |
39
|
|
|
/** @var Warehouse $warehouse */ |
40
|
|
|
$warehouse = Warehouse::createFromJson(getcwd() . "/../resources/biggerWarehouse.json"); |
41
|
|
|
$calculatedArray = $warehouse->getPlaces(); |
42
|
|
|
|
43
|
|
|
$warehouse->setPathCalculator(new ShortPathCalculator()); |
44
|
|
|
|
45
|
|
|
/** @var Place[] $arrayNodes */ |
46
|
|
|
$arrayNodes = $this->chooseSearchablePlaces($calculatedArray); |
47
|
|
|
|
48
|
|
|
$matrix = $warehouse->getMultiplePath($arrayNodes); |
49
|
|
|
|
50
|
|
|
$this->printTable($output, $arrayNodes, $matrix); |
51
|
|
|
|
52
|
|
|
$warehouse->calculate($arrayNodes, $matrix); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Output the table for debug purpose |
57
|
|
|
* |
58
|
|
|
* @param OutputInterface $output |
59
|
|
|
* @param array $arrayNodes |
60
|
|
|
* @param array $matrix |
61
|
|
|
*/ |
62
|
|
|
private function printTable(OutputInterface $output, array $arrayNodes, array $matrix) |
63
|
|
|
{ |
64
|
|
|
$table = new Table($output); |
65
|
|
|
$table |
66
|
|
|
->setHeaders($arrayNodes) |
67
|
|
|
->setRows($matrix) |
68
|
|
|
; |
69
|
|
|
$table->render(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Select the Places for find the path |
74
|
|
|
* |
75
|
|
|
* @param Place[] $calculatedArray |
76
|
|
|
* @return Place[] |
77
|
|
|
*/ |
78
|
|
|
private function chooseSearchablePlaces($calculatedArray) |
79
|
|
|
{ |
80
|
|
|
return array( |
81
|
|
|
$calculatedArray[103], |
82
|
|
|
$calculatedArray[30], |
83
|
|
|
$calculatedArray[23], |
84
|
|
|
$calculatedArray[57], |
85
|
|
|
$calculatedArray[135], |
86
|
|
|
$calculatedArray[120], |
87
|
|
|
$calculatedArray[115], |
88
|
|
|
$calculatedArray[79], |
89
|
|
|
$calculatedArray[601], |
90
|
|
|
$calculatedArray[650] |
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths