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

mple()   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\Calculator\FastCalculator;
6
use GGGGino\WarehousePath\Entity\Place;
7
use GGGGino\WarehousePath\JsonReader;
8
use GGGGino\WarehousePath\Warehouse;
9
use GGGGino\WarehousePath\WarehouseTree;
0 ignored issues
show
Bug introduced by
The type GGGGino\WarehousePath\WarehouseTree was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Symfony\Component\Console\Command\Command;
11
use Symfony\Component\Console\Helper\Table;
12
use Symfony\Component\Console\Input\InputArgument;
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
use WarehouseMatrixTest;
16
17
class MultiplePathGraphicalTestCommand extends Command
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    protected function configure()
23
    {
24
        $this
25
            ->setName('ggggino:warehouse:mpg-print-matrix')
26
            ->setDescription('Print a beautiful matrix with the lenght of every path')
27
            ->setHelp(<<<EOT
28
Print a beautiful matrix.
29
EOT
30
            );
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function execute(InputInterface $input, OutputInterface $output)
37
    {
38
        /** @var Warehouse $warehouse */
39
        $warehouse = Warehouse::createFromJson(getcwd() . "/../resources/biggerWarehouse.json");
40
        $calculatedArray = $warehouse->getPlaces();
41
42
        $warehouse->setPathCalculator(new FastCalculator());
43
44
        /** @var Place[] $arrayNodes */
45
        $arrayNodes = $this->chooseSearchablePlaces($calculatedArray);
46
47
        $matrix = $warehouse->getMultiplePath($arrayNodes);
48
49
        $this->printTable($output, $arrayNodes, $matrix);
50
51
        $warehouse->calculate($arrayNodes, $matrix);
52
    }
53
54
    /**
55
     * Output the table for debug purpose
56
     *
57
     * @param OutputInterface $output
58
     * @param array $arrayNodes
59
     * @param array $matrix
60
     */
61
    private function printTable(OutputInterface $output, array $arrayNodes, array $matrix)
62
    {
63
        $table = new Table($output);
64
        $table
65
            ->setHeaders($arrayNodes)
66
            ->setRows($matrix)
67
        ;
68
        $table->render();
69
    }
70
71
    /**
72
     * Select the Places for find the path
73
     *
74
     * @param Place[] $calculatedArray
75
     * @return Place[]
76
     */
77
    private function chooseSearchablePlaces($calculatedArray)
78
    {
79
        return array(
80
            $calculatedArray[103],
81
            $calculatedArray[30],
82
            $calculatedArray[23],
83
            $calculatedArray[57],
84
            $calculatedArray[135],
85
            $calculatedArray[120],
86
            $calculatedArray[115],
87
            $calculatedArray[79],
88
            $calculatedArray[601],
89
            $calculatedArray[650]
90
        );
91
    }
92
}
93