/** * Normalizes information on a given model. * * This method takes * * - name of a model's class * - instance of a model * - reflection on a model's class * * and returns the reflection on a model's class. * * @throws \InvalidArgumentException if provided class isn't derived from class model * @param model|string|\ReflectionClass $model information on model to normalize * @return \ReflectionClass reflection on class of given model */ public static function normalizeModel($model) { if ($model instanceof self) { return $model->getReflection(); } if (is_string($model)) { $model = trim($model); if ($model[0] != '\\') { $model = '\\de\\toxa\\txf\\' . $model; } $model = new \ReflectionClass($model); } if (!$model instanceof \ReflectionClass) { throw new \InvalidArgumentException('invalid model information'); } if (!$model->isSubclassOf(__NAMESPACE__ . '\\model')) { throw new \InvalidArgumentException('no such model'); } return $model; }