- Work done on CLI package

This commit is contained in:
Dave Mc Nicoll committed 2025-09-19 13:12:18 +00:00
1 parent 6d771ed88f
commit d08d1f0fe7
15 files changed
+482 -38

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
<?php
namespace Mcnd\CLI\Option;
class KeyValueOption extends ParsedOption
{
protected array $values = [];
public function setValue(string $key, string $value) : void
{
$this->values[$key] = $value;
}
public function setRawValue(string $value) : void
{
if (! str_contains($value, '=')) {
throw new \RuntimeException(sprintf("A key=value notation was awaited, received %s instead", $value));
}
list($key, $value) = explode('=', trim($value), 2);
$this->setValue($key, $value);
}
public function getValue() : null|array
{
return $this->values ?: null;
}
}