private function findInReflectionClass(\ReflectionClass $refl, string $type, string $name) { $_ = StringUtil::classify($type); $has = 'has' . $_; $get = 'get' . $_; if (!method_exists($refl, $has) || !method_exists($refl, $get)) { throw new \InvalidArgumentException(sprintf('Cannot find by %s in ReflectionClass', $type)); } $ref = new \ReflectionClass($refl->getName()); while (!call_user_func([$ref, $has], $name)) { if ($ref = $ref->getParentClass()) { continue; } throw new \InvalidArgumentException(sprintf('Property %s does not exist in %s', $name, $refl->getName())); } return call_user_func([$ref, $get], $name); }
/** * @param ColumnInterface $column * @param $retType * * @return string */ private function buildGetterName(ColumnInterface $column, $retType) : string { return ($retType === ColumnTypeHelper::TYPE_BOOLEAN ? 'is' : 'get') . StringUtil::classify($column->getField()); }