findAccessorMethodName($class, $camelCaseProperty, $getterName, $boolGetterName); } /** * Find the setter method name for a property from the given class * * @param ClassReflection $class * @param string $camelCaseProperty * @return string processed method name * @throws \LogicException If $camelCaseProperty has no corresponding setter method */ public function getSetterMethodName(ClassReflection $class, $camelCaseProperty) { $setterName = 'set' . $camelCaseProperty; $boolSetterName = 'setIs' . $camelCaseProperty; return $this->findAccessorMethodName($class, $camelCaseProperty, $setterName, $boolSetterName); } /** * Find the accessor method name for a property from the given class * * @param ClassReflection $class * @param string $camelCaseProperty * @param string $accessorName * @param bool $boolAccessorName * @return string processed method name * @throws \LogicException If $camelCaseProperty has no corresponding setter method */ public function findAccessorMethodName( ClassReflection $class, $camelCaseProperty, $accessorName, $boolAccessorName ) { if ($this->hasMethod($class, $accessorName)) { $methodName = $accessorName; return $methodName; } elseif ($this->hasMethod($class, $boolAccessorName)) { $methodName = $boolAccessorName; return $methodName; } else { throw new \LogicException( sprintf( 'Property "%s" does not have corresponding setter in class "%s".', $camelCaseProperty, $class->getName() ) ); } } /** * Checks if method is defined * * Case sensitivity of the method is taken into account. * * @param ClassReflection $class * @param string $methodName * @return bool */ public function hasMethod(ClassReflection $class, $methodName) { return $class->hasMethod($methodName) && ($class->getMethod($methodName)->getName() == $methodName); } }