Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 2, 2023
1 parent fa522be commit c1408c9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/CLI/ArgumentsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
*/
namespace SebastianBergmann\PHPLOC;

use function array_values;
use function assert;
use function is_array;
use function is_string;
use SebastianBergmann\CliParser\Exception as CliParserException;
use SebastianBergmann\CliParser\Parser as CliParser;

Expand Down Expand Up @@ -42,21 +44,33 @@ public function build(array $argv): Arguments
);
}

$directories = $options[1];
$directories = [];
$exclude = [];
$suffixes = ['.php'];
$debug = false;
$help = false;
$version = false;

foreach ($options[1] as $directory) {
assert(is_string($directory) && !empty($directory));

$directories[] = $directory;
}

foreach ($options[0] as $option) {
assert(is_array($option));

switch ($option[0]) {
case '--suffix':
assert(is_string($option[1]) && !empty($option[1]));

$suffixes[] = $option[1];

break;

case '--exclude':
assert(is_string($option[1]) && !empty($option[1]));

$exclude[] = $option[1];

break;
Expand Down Expand Up @@ -87,7 +101,7 @@ public function build(array $argv): Arguments
}

return new Arguments(
array_values($directories),
$directories,
$suffixes,
$exclude,
$debug,
Expand Down

0 comments on commit c1408c9

Please sign in to comment.