/** * @depends test_construct * @covers ::__unset */ public function test_unset() { # Name try { unset($this->Option->Name); $this->fail('Failed to generate notice with readonly property'); } catch (\PHPUnit_Framework_Error_Notice $e) { $this->assertContains('Cannot modify readonly property', $e->getMessage(), 'Invalid notice: ' . $e->getMessage()); } @$this->Option->__unset('Name'); # Value try { unset($this->Option->Value); $this->fail('Failed to generate notice with readonly property'); } catch (\PHPUnit_Framework_Error_Notice $e) { $this->assertContains('Cannot modify readonly property', $e->getMessage(), 'Invalid notice: ' . $e->getMessage()); } @$this->Option->__unset('Value'); # Undefined unset($this->Option->undefined); }
/** * 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); } }