/** * @covers ::splitCommandLine */ public function test_splitCommandLine() { $Expected = array('command', 'file.txt', '-a', 'value for a', '-b', "value \\' for b", '-c', 'value \\" for c', '-d', 'value for d', '-e1', 'foo', '-f', '--g', 'gvalue', '--h=', 'value for h', '--i=1', '--j', 'jvalue', '-k', "\n\n\r\n", '-x', 'arg1', 'arg2', 'http://example.com', "\n\n\r\n"); $this->assertEquals($Expected, $this->Option->splitCommandLine(self::COMMANDLINE), 'AOption::_splitCommandLine() returned an invalid value'); }
/** * Creates an instance of IContainer containing arguments parsed from a string. * * @uses \BLW\Type\Command\IOption::splitCommandLine() IOption::splitCommandLine() * * @throws \BLW\Model\InvalidArgumentException If <code>$Arguments</code> is not a <code>string</code>. * * @param string $Arguments * String containing commandline. * @param array $NoValue * Array of options that have no value. * @return \BLW\Type\IContainer Instance of <code>IContainer</code> containing parsed arguments. Returns <code>FALSE</code> on error. */ public static function createFromString($Arguments, array $NoValue = array()) { // Is $Arguments scalar? if (is_string($Arguments) ?: is_callable(array($Arguments, '__toString'))) { // Create IContainer return self::createFromArray(AOption::splitCommandLine($Arguments), $NoValue); // Invalid $Arguments } else { throw new InvalidArgumentException(0); } }