/** * @param string $className * * @return array */ protected static function getClassProperties($className) { if (\class_exists($className, true)) { $reflection = new ReflectionClass($className); $value = $reflection->newInstanceWithoutConstructor(); if (\is_subclass_of($value, Model::class, true)) { $attributes = Schema::getColumnListing($value->getTable()); self::$eloquentClasses[$className] = $attributes; } } return !empty(self::$eloquentClasses[$className]) ? self::$eloquentClasses[$className] : parent::getClassProperties($className); }
/** * @param string $className * * @return array */ protected static function getClassProperties($className) { if (\class_exists($className, true)) { $reflection = new ReflectionClass($className); $value = $reflection->newInstanceWithoutConstructor(); if (\is_subclass_of($value, Model::class, true)) { $attributes = \array_merge(Schema::getColumnListing($value->getTable()), self::getRelationshipMethodsAsPropertyName($value, $className, $reflection)); self::$eloquentClasses[$className] = $attributes; return self::$eloquentClasses[$className]; } } return parent::getClassProperties($className); }
public function testItWillThrowExceptionIfArrayHasNoSelfUrlKey() { $this->expectException(MappingException::class); $mappedClass = ['class' => Post::class, 'id_properties' => ['postId'], 'urls' => []]; MappingFactory::fromArray($mappedClass); }