Skip to content

Commit f95e6f5

Browse files
committed
updated formatters
1 parent e4f8e7c commit f95e6f5

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

src/Differs/FilesDiffCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ function ($differenceDescriptor, $fileKey) {
381381
/**
382382
* @return array<int,mixed>
383383
*/
384-
private function getFileDataItems(CLPI $command, FPI $fileParser): array {
384+
private function getFileDataItems(CLPI $command, FPI $fileParser): array
385+
{
385386
$fileNames = $command->getFileNames();
386387
$this->filesPaths = [
387388
$fileNames['FILE1'],

src/Formatters/PlainCommand.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,18 @@ private function plainContent(array $content): array
3434
$result = array_reduce(
3535
$content,
3636
function ($result, $contentItem) {
37-
if (is_array($contentItem)) {
38-
if (is_array($contentItem["output"])) {
39-
if (sizeof($contentItem["output"]) > 0) {
40-
if (is_array($result)) {
41-
$result[] = implode($this->plainContent($contentItem["output"])) .
42-
"\n";
43-
}
44-
} else {
45-
if (is_array($result)) {
46-
$strHistory = is_string($contentItem['history']) ? $contentItem['history'] : "";
47-
$strFileContent = $this->normalizeValue($contentItem["fileContent"]);
48-
$result[] = "Property '{$strHistory}' has value " .
49-
"{$strFileContent}\n";
50-
}
51-
}
52-
}
37+
if (
38+
is_array($contentItem) &&
39+
is_array($contentItem["output"]) &&
40+
is_array($result)
41+
) {
42+
$strHistory = is_string($contentItem['history']) ? $contentItem['history'] : "";
43+
$strFileContent = $this->normalizeValue($contentItem["fileContent"]);
44+
45+
$result[] = (sizeof($contentItem["output"]) > 0) ?
46+
implode($this->plainContent($contentItem["output"])) . "\n"
47+
:
48+
"Property '{$strHistory}' has value " . "{$strFileContent}\n";
5349
}
5450

5551
return $result;

src/Formatters/StylishCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,12 @@ public function execute(\Differ\Interfaces\FilesDiffCommandInterface $command):
314314
$this->statusKeys[2] => " + ",
315315
$this->statusKeys[3] => " - "
316316
];
317+
317318
$altStatusComments = [];
318319
foreach ($this->statusKeys as $key) {
319320
$altStatusComments[$key] = "";
320321
}
322+
321323
$this->statusComments = (strcmp($this->commentType, self::AVAILABLE_COMMENT_TYPES["verbose"]) === 0) ?
322324
[
323325
$this->statusKeys[0] => "",

0 commit comments

Comments
 (0)