Skip to content

Commit

Permalink
fix: protect against empty key_value pair list
Browse files Browse the repository at this point in the history
  • Loading branch information
Thijzer committed May 29, 2024
1 parent 83d438d commit 17d7628
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Component/Action/KeyMapperAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function apply(array $item): array
return $item;
}

$list = $this->getOption('list');
$list = array_filter($this->getOption('list'));
// when dealing with converted data we need the primary keys
// we just need to replace these keys
$newList = [];
Expand Down
3 changes: 2 additions & 1 deletion src/Component/Debugger/ItemDebugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ItemDebugger
{
public function log($item, $message)
{
dump($message, TypeGuesser::guess($item));
dump($message, $item);
//dump($message, TypeGuesser::guess($item));
}
}
11 changes: 9 additions & 2 deletions src/Component/Source/Command/SourceKeyValueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,24 @@ class SourceKeyValueCommand implements SourceAwareInterface, ExecuteSourceComman
'list' => null,
'key' => null,
'value' => null,
'key_prefix' => ''
'key_prefix' => '',
'display_empty_values' => true,
];

public function execute(): array
{
return KeyValuePairBuilder::build(
$list = KeyValuePairBuilder::build(
$this->getSource()->getCachedReader(),
$this->getOption('key'),
$this->getOption('value'),
$this->getOption('key_prefix'),
);

if (true !== $this->getOption('display_empty_values')) {
return array_filter($list);
}

return $list;
}

public function executeWithOptions(array $options)
Expand Down

0 comments on commit 17d7628

Please sign in to comment.