* @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:----QFscpuQgeyhJhKZcjygJgQ3wvneUzne8go+J5Y9KKbCiGIkFTK/bV2mpFoWrI86Nwk+zj9o9ajpn9283i96x0jWMm0bPLJbe1Ee1OyFZKS5F6hCtFsPnRFM5IrdxXQ/gJeFA/nhWcItXTPmuOBIm4sUKaw/OHw+2hlSqNmRfOjafC2cTFeSh0DeKNYnzVuV0DtQPmAOY6bB50FtyOK4qBXGpJ6sahHRRgAn/3PK+fgrKp5AlEYHF0tbX8mJDbRDhVq1oaaKJoFkQTHjuedAwbzoKDzTwUtFiHEJNgSDb6FTO8q9rpOMEiVWtbGPvvT5mbtG7QGOihJc5bWGOAmFeXmBs2+oFvJUlYyZ3CqAIaO5UW5M/kilrMbWASHhDX2S/SS/gq/yNZ3NRprnifBDVRXuZtxQAzB+C2bGWLGhNX8GiUxgzHi6m+EQUF2pkRkXv02JKPfovQ3mw7F0Eij6l98a0cVjfNdm6sdTMjnyHafubNxQEJbk2SQ2hCMXh5vkRG4SHeoPb/3XRPQn/cusRaBCHyqqkRttwPh9QC0b+DgSqmJCq3wj1msPL3jDncdL23Fblhn2d3UzxLtdNQz0zA5KEv68aWq+l4xwqjnbZe6LewpVnfSPAsJX1nNPtsTMHb3oJ4t4DPtCvCe+2bSAQZ5PaW32QVsqJNtacSlRgilA=----ATTACHMENT:----NTk5MjY3NTc0OTkzMjYwNSA1NDg5MjkwMDgwMTk3ODQ5IDY2MDc5MjU5NTM5MTY2Nw==