These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @author stev leibelt <[email protected]> |
||
4 | * @since 2017-01-31 |
||
5 | */ |
||
6 | use Net\Bazzline\Component\ApacheServerStatusParser\DomainModel\ReduceDataAbleToArrayInterface; |
||
7 | |||
8 | require __DIR__ . '/../../vendor/autoload.php'; |
||
9 | |||
10 | //begin of helper functions |
||
11 | /** |
||
12 | * @param array $array |
||
13 | * @param string $prefix |
||
14 | */ |
||
15 | View Code Duplication | function dumpArray(array $array, $prefix = ' ') |
|
16 | { |
||
17 | foreach ($array as $item => $value) { |
||
18 | if ($value instanceof ReduceDataAbleToArrayInterface) { |
||
19 | echo $prefix . $item . PHP_EOL; |
||
20 | dumpArray($value->reduceDataToArray(), str_repeat($prefix, 2)); |
||
21 | } else if (is_array($value)) { |
||
22 | echo $prefix . $item . PHP_EOL; |
||
23 | dumpArray($value, str_repeat($prefix, 2)); |
||
24 | } else { |
||
25 | echo $prefix . $item . ': ' . $value . PHP_EOL; |
||
26 | } |
||
27 | } |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param array $lines |
||
32 | * @param string $name |
||
33 | */ |
||
34 | View Code Duplication | function dumpSectionIfThereIsSomeContent(array $lines, $name) |
|
35 | { |
||
36 | if (!empty($lines)) { |
||
37 | echo '==== ' . $name . ' ====' . PHP_EOL; |
||
38 | echo PHP_EOL; |
||
39 | |||
40 | dumpArray($lines); |
||
41 | |||
42 | echo PHP_EOL; |
||
43 | } |
||
44 | } |
||
45 | //end of helper functions |
||
46 | |||
47 | //begin of dependencies |
||
48 | $listOfNameToElapsedTime = []; |
||
49 | $parserBuilderFactory = new \Net\Bazzline\Component\ApacheServerStatusParser\Service\Builder\ParserBuilderFactory(); |
||
50 | $storageBuilder = new \Net\Bazzline\Component\ApacheServerStatusParser\Service\Builder\RemoteStorageBuilder(); |
||
51 | $urlToTheExampleFile = ( |
||
52 | ($argc > 1) |
||
53 | ? $argv[1] |
||
54 | : 'http://testdata.bazzline.net/apache_server_status/index.html' |
||
55 | ); |
||
56 | |||
57 | $parserBuilder = $parserBuilderFactory->create(); |
||
58 | //end of dependencies |
||
59 | |||
60 | //begin of business logic |
||
61 | PHP_Timer::start(); |
||
62 | |||
63 | $storageBuilder->setUrlToTheApacheStatusFileToParseUpfront($urlToTheExampleFile); |
||
64 | $storageBuilder->selectParseModeAllUpfront(); |
||
65 | $storageBuilder->build(); |
||
66 | |||
67 | $listOfNameToElapsedTime['fetching'] = PHP_Timer::secondsToTimeString( |
||
68 | PHP_Timer::stop() |
||
69 | ); |
||
70 | |||
71 | $storage = $storageBuilder->andGetStorageAfterTheBuild(); |
||
72 | |||
73 | dumpSectionIfThereIsSomeContent($storage->getListOfInformation(), 'Information'); |
||
74 | dumpSectionIfThereIsSomeContent($storage->getListOfDetail(), 'Detail'); |
||
75 | dumpSectionIfThereIsSomeContent($storage->getListOfScoreboard(), 'Scoreboard'); |
||
76 | dumpSectionIfThereIsSomeContent($storage->getListOfStatistic(), 'Statistic'); |
||
77 | |||
78 | PHP_Timer::start(); |
||
79 | |||
80 | $parserBuilder->setStorageUpfront($storage); |
||
81 | $parserBuilder->build(); |
||
82 | |||
83 | $listOfNameToElapsedTime['parsing'] = PHP_Timer::secondsToTimeString( |
||
84 | PHP_Timer::stop() |
||
85 | ); |
||
86 | |||
87 | dumpSectionIfThereIsSomeContent( |
||
88 | $parserBuilder->andGetListOfDetailOrNullAfterwards(), |
||
0 ignored issues
–
show
|
|||
89 | 'Parsed Detail' |
||
90 | ); |
||
91 | |||
92 | dumpSectionIfThereIsSomeContent( |
||
93 | [ |
||
94 | $parserBuilder->andGetInformationOrNullAfterwards() |
||
95 | ], |
||
96 | 'Parsed Information' |
||
97 | ); |
||
98 | |||
99 | dumpSectionIfThereIsSomeContent( |
||
100 | [ |
||
101 | $parserBuilder->andGetScoreboardOrNullAfterwards() |
||
102 | ], |
||
103 | 'Parsed Scoreboard' |
||
104 | ); |
||
105 | |||
106 | dumpSectionIfThereIsSomeContent( |
||
107 | [ |
||
108 | $parserBuilder->andGetStatisticOrNullAfterwards() |
||
109 | ], |
||
110 | 'Parsed Statistic' |
||
111 | ); |
||
112 | |||
113 | foreach ($listOfNameToElapsedTime as $name => $elapsedTime) { |
||
114 | echo $name . ' took: ' . $elapsedTime . PHP_EOL; |
||
115 | } |
||
116 | //end of business logic |
||
117 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.