/** * Constructor. * * @param string $class The class this property is defined on * @param string $name The name of this property */ public function __construct($class, $name) { if (!property_exists($class, $name)) { throw new ValidatorException(sprintf('Property %s does not exists in class %s', $name, $class)); } parent::__construct($class, $name, $name); }
/** * Constructor. * * @param string $class The class the getter is defined on * @param string $property The property which the getter returns */ public function __construct($class, $property) { $getMethod = 'get' . ucfirst($property); $isMethod = 'is' . ucfirst($property); if (method_exists($class, $getMethod)) { $method = $getMethod; } else { if (method_exists($class, $isMethod)) { $method = $isMethod; } else { throw new ValidatorException(sprintf('Neither method %s nor %s exists in class %s', $getMethod, $isMethod, $class)); } } parent::__construct($class, $method, $property); }