/** * traverse a list held in an object * * @param object $list * the list to walk * @param string $listName * what is the name of $list in the calling code? * @param callable $callable * what are we calling * @return void */ public static function using($list, $listName, callable $callable) { // robustness! if (!IsListyObject::check($list)) { throw new InvalidArgumentException($listName . ' cannot be traversed as a list'); } foreach ($list as $key => $data) { $name = $listName . '->' . quote_property($key); $callable($data, $key, $name); } }
/** * @covers ::quote_property * @expectedException InvalidArgumentException */ public function test_throws_InvalidArgumentException_for_resources() { // ---------------------------------------------------------------- // setup your test $name = STDIN; // ---------------------------------------------------------------- // perform the change $actualName = quote_property($name); // ---------------------------------------------------------------- // test the results }