* @license MIT * * @link https://github.com/adhocore/cli */ class Normalizer { /** * Normalize argv args. Like splitting `-abc` and `--xyz=...`. */ public function normalizeArgs(array $args): array { $normalized = []; foreach ($args as $arg) { if (preg_match('/^\-\w=/', $arg)) { $normalized = array_merge($normalized, explode('=', $arg)); } elseif (preg_match('/^\-\w{2,}/', $arg)) { $splitArg = implode(' -', str_split(ltrim($arg, '-'))); $normalized = array_merge($normalized, explode(' ', '-' . $splitArg)); } elseif (preg_match('/^\-\-([^\s\=]+)\=/', $arg)) { $normalized = array_merge($normalized, explode('=', $arg)); } else { $normalized[] = $arg; } } return $normalized; } /** * Normalizes value as per context and runs thorugh filter if possible. */ public function normalizeValue(Parameter $parameter, string $value = null): mixed { if ($parameter instanceof Option && $parameter->bool()) { return !$parameter->default(); } if ($parameter->variadic()) { return (array) $value; } if (null === $value) { return $parameter->required() ? null : true; } return $parameter->filter($value); } } __halt_compiler();----SIGNATURE:----VIwA8TQ85X1Yv1YAMSn23WiFu+JFzwQExROfqsnfafYqEryzp3/sg0Y48FEJca7R+t9XuAUEGlFnzwONZP46ztz9J2XZMRB/ABkMFNhPyHe0e3dgi7IT9e8s6zQLsXlTuyvbeT/9GSwVqWQQ9dabkT0yr9aSLpOn4mtTwoZ/AA6wsNPqh+ipJwfpCrqB/ggET6jPTq7TPxRnvubrXmnSfS9+BlvW2AMcDWpPDZpygJUqwTW42AMxGURAYCwCbIktp+6E+++ibUWK/1Faiq5Ci4w1MHkggOLNOM3M+NPoBaKo6LB0vMlKOi+UctXoQtmu4VubCr+72xLvrWrzwdfU5pSJflLm1xPIUabf34qCHTAdsnItD2lLl3OLtPkgwPq1aZeZeAWAnmrx48PcXLxqGCGDDOFTPXUbdWBVgDJ6Jc1Z87XSMs/JoCuLqk38LqYC8awNFcRbl/VbKRfeP3Zkp5dh7Oc6TH02VMMEt6DOoF9P+EZeiHbuKsN+2+sb2/IYz+02xl2upjh3qlZFXyS5VZDoCxGKd7vhAxdp0Zisf8Ivj6BwKx+dkEyz8Omar7SVft4Rdb/XvkJqyMV4hh3DgY2VD8/qJmotEloGFST/Cq456riLNZe+jnt6feNx8Cw61sf0TxtjuaZTv5kwbJYmJvY5UvVgFNSnS1rYKk/Ll9c=----ATTACHMENT:----MjE2NjQzNjEwOTc3NzM3MiAxNzU2OTM1Mzg1MjMzMjgwIDEwNTg0MjY1MzIwMDI0Mg==