[OutputEscaper] Added magic __isset() method to object escaper.

This commit is contained in:
Kris Wallsmith 2010-07-09 06:18:08 -07:00
parent ab26f9f3bf
commit fe7e01c653
2 changed files with 18 additions and 0 deletions

View File

@ -106,4 +106,16 @@ class ObjectDecorator extends GetterDecorator
{
return $this->escape($this->escaper, $this->value->$key);
}
/**
* Checks whether a value is set on the wrapped object.
*
* @param string $key The name of the value to check
*
* @return boolean Returns true if the value is set
*/
public function __isset($key)
{
return isset($this->value->$key);
}
}

View File

@ -41,6 +41,12 @@ class ObjectDecoratorTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals('<em>escape me</em>', self::$escaped->someMember, 'The escaped object behaves like the real object');
}
public function testMagicIsset()
{
$this->assertTrue(isset(self::$escaped->someMember), 'The escaped object behaves like the real object');
$this->assertFalse(isset(self::$escaped->invalidMember), 'The escaped object behaves like the real object');
}
}
class OutputEscaperTest