<?php
class JSONConverter
{
private function createClassInstanceFromRowSet($className, $rowSet)
{
$collection = array();
foreach($rowSet as $row) {
$collection[] = new $className($row);
}
return $collection;
}
public function __call($method, $args)
{
if (!preg_match('/^create(.+?)FromRowSet$/i', $method, $matches) {
throw new \LogicException('Invalid conversion method: ' . $method);
} else if (!class_exists($matches[1])) {
throw new \LogicException('Invalid class name: ' . $matches[1]);
} else if (!isset($args[0]) || !($args[0] instanceof Zend_Db_RowSet)) {
throw new \LogicException('Invalid row set argument');
}
// you could also verify that is_subclass_of($matches[1], 'CommonParent') if you want
return $this->createClassInstanceFromRowSet($matches[1], $args[0]);
}
}
Parse error: syntax error, unexpected T_STRING in /in/VHI5r on line 7
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/VHI5r on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/VHI5r on line 5
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/VHI5r on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/VHI5r on line 5
Process exited with code 255.