Conditions | 3 |
Paths | 2 |
Total Lines | 26 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function consolidate($userProvidedPathToConsolidate, StyleInterface $ioStyle = null) |
||
19 | { |
||
20 | if ($ioStyle === null) { |
||
21 | $ioStyle = new NullStyle(); |
||
22 | } |
||
23 | $ioStyle->progressStart(4); |
||
24 | |||
25 | $pathToConsolidate = FileSystem::getRealPathToReadableAndWritableFile($userProvidedPathToConsolidate); |
||
26 | if (!$pathToConsolidate) { |
||
|
|||
27 | $message = $userProvidedPathToConsolidate . ' has to be a file both readable and writable.'; |
||
28 | $ioStyle->error($message); |
||
29 | throw new \InvalidArgumentException($message); |
||
30 | } |
||
31 | $ioStyle->progressAdvance(); |
||
32 | |||
33 | $usedFiles = FileSystem::readFileIntoArray($pathToConsolidate); |
||
34 | $ioStyle->progressAdvance(); |
||
35 | |||
36 | $usedFiles = array_unique($usedFiles); |
||
37 | sort($usedFiles); |
||
38 | $ioStyle->progressAdvance(); |
||
39 | |||
40 | FileSystem::writeArrayToFile($usedFiles, $pathToConsolidate); |
||
41 | $ioStyle->progressFinish(); |
||
42 | |||
43 | $ioStyle->success('Finished consolidating ' . $pathToConsolidate); |
||
44 | } |
||
46 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: