* @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:----TZM2S3fax/UXAfcSzOyBpd1zkaeEubooGZMqOklAQwBg31s3wjJ7MGr6aaMVg/ZuttI/xRHisenDyBmijdxEcNGHMdtKYP69ruc4+diMJ4fgeX3apC7hQpcInmc6ZoyfGiaxWdNc1jnHcC3LDUDFJ09bMx6dY6Laq2nJmaJJxn1HcL0Rd8hLJ3GWbORS70NcMR4v+s1SHWPcDl5IFkwhYv/KYm4nFKSmWtiZfApg1QNaup8CH+Sj84jJqDPAn3/cqvWPy7ad4QqhR0JNKc8cSHm/QoZ1c0dmfclFWjsgnZCP8HMU85i29L6Q3/bquFgekD4scPeaTpbOnv0qrRRUOTqhaPICwpn3NeAjnkeT7qL4OBEBdX2mHeMFNVo+AX1RNnyFbPYFtRvqTqssFRe+chsNyA14RQkR1sdxQcTmy7iGyQpSh630VUWoWpZ9UOiwEPk73YenBnS6Us9NpQtOII/RPLJC/FDLiG67B5Y+bfUXVajcI4YevVzsQEEefNc8qFWsafb7J9q3hecmZBecCJjWmql15LcS7BR6CX+YIW9T7Jj+86oqYoeZyjMfVWfJq4dgB0jgcbA7TNdmRAta359w7tQk3a4gTsDMftKjqnQOlz9u5jnfiPFu80/VRMqljWG+wFLLNFA34rpWiQ1U4jk7WYJ2eXNLCaNQusRNRPY=----ATTACHMENT:----NzYwMzUxMjQzOTAzMjY5MiA0NjEyNjIwMzc0ODYzMTU2IDcxNDM4OTU4MjMxOTkyNjk=