Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
Playaround with cyclomatic complexity.
Browse files Browse the repository at this point in the history
  • Loading branch information
lakiboy committed Aug 30, 2018
1 parent 68800be commit 4602a4e
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/Bridge/Symfony/Console/Command/RosfinLookupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,24 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 0;
}

$format = function (RosfinItem $terrorist): array {
return [
['ID', $terrorist->id()],
['Type', $terrorist->type()],
['Full name', implode("\n", $terrorist->fullName())],
['Birth date', $terrorist->birthDate() ?: '-'],
['Birth place', $terrorist->birthPlace() ?: '-'],
['Description', $terrorist->description() ? mb_substr($terrorist->description(), 0, 120) : '-'],
['Address', $terrorist->address() ?: '-'],
['Resolution', $terrorist->resolution() ?: '-'],
['Passport', $terrorist->passport() ?: '-'],
];
};

foreach ($check as $item) {
$io->newLine();
$io->table(['Field', 'Value'], $format($item));
$io->table(['Field', 'Value'], $this->formatItem($item));
}
}

private function formatItem(RosfinItem $terrorist): array
{
return [
['ID', $terrorist->id()],
['Type', $terrorist->type()],
['Full name', implode("\n", $terrorist->fullName())],
['Birth date', $terrorist->birthDate() ?: '-'],
['Birth place', $terrorist->birthPlace() ?: '-'],
['Description', $terrorist->description() ? mb_substr($terrorist->description(), 0, 120) : '-'],
['Address', $terrorist->address() ?: '-'],
['Resolution', $terrorist->resolution() ?: '-'],
['Passport', $terrorist->passport() ?: '-'],
];
}
}

0 comments on commit 4602a4e

Please sign in to comment.