$data = array("id" => 1, "name" => "Chris", "biography" => "I am am a PHP developer");
foreach($data as $key => $value) {if(!$class->hasProperty($key)) {throw new Exception($key." is not a valid property"); }
if(!$class->hasMethod("get".($key))) {throw new Exception($key." is missing a getter"); }
if(!$class->hasMethod("set".($key))) {throw new Exception($key." is missing a setter"); }
// Make a new object to interact with $object = new Person();
// Get the getter method and invoke it with the value in our data array
$setter = $class->getMethod("set".($key));
$ok = $setter->invoke($object, $value);
// Get the setter method and invoke it
$setter = $class->getMethod("get".($key));
$objValue = $setter->invoke($object);
// Now compare
if($value == $objValue) {
echo "Getter or Setter has modified the data.\n";
} else {
echo "Getter and Setter does not modify the data.\n";
}