1<?php 2/* 3 * This file is part of PHPUnit. 4 * 5 * (c) Sebastian Bergmann <sebastian@phpunit.de> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11/** 12 * Constraint that asserts that the object it is evaluated for has a given 13 * attribute. 14 * 15 * The attribute name is passed in the constructor. 16 */ 17class PHPUnit_Framework_Constraint_ObjectHasAttribute extends PHPUnit_Framework_Constraint_ClassHasAttribute 18{ 19 /** 20 * Evaluates the constraint for parameter $other. Returns true if the 21 * constraint is met, false otherwise. 22 * 23 * @param mixed $other Value or object to evaluate. 24 * 25 * @return bool 26 */ 27 protected function matches($other) 28 { 29 $object = new ReflectionObject($other); 30 31 return $object->hasProperty($this->attributeName); 32 } 33} 34