/** * Load the config. * * @param string $argv The command line string. */ public function loadConfig($argv = []) { $args = new Args(); $args->argument('config', ['default' => 'kahlan-config.php']); $args->argument('help', ['type' => 'boolean']); $args->argument('version', ['type' => 'boolean']); $args->parse($argv); $run = function ($args) { if (file_exists($args->get('config'))) { require $args->get('config'); } }; $run($args); $this->_args->parse($argv, false); if ($args->get('help')) { return $this->_help(); } if ($args->get('version')) { return $this->_version(); } }
foreach ($cast as $c) { expect($c)->toBeA('string'); } }); it("casts boolean", function () { $args = new Args(); $cast = $args->cast(["true", "false", "some_string", null, 10], "boolean"); expect($cast)->toBeAn('array'); expect(count($cast))->toBe(5); list($bTrue, $bFalse, $string, $null, $number) = $cast; expect($bTrue)->toBeA('boolean')->toBe(true); expect($bFalse)->toBeA('boolean')->toBe(false); expect($string)->toBeA('boolean')->toBe(true); expect($null)->toBeA('boolean')->toBe(false); expect($number)->toBeA('boolean')->toBe(true); }); it("casts numeric", function () { $args = new Args(); $cast = $args->cast([true, "false", "some_string", null, 10], "numeric"); expect($cast)->toBeAn('array'); expect(count($cast))->toBe(5); expect(implode($cast))->toBe("100110"); }); it("casts value into array", function () { $args = new Args(); $cast = $args->cast("string", "string", true); expect($cast)->toBeA("array"); expect($cast)->toContain("string"); }); }); });