BookStack\Entity::getEntityInstance PHP Method

getEntityInstance() public static method

Get an instance of an entity of the given type.
public static getEntityInstance ( $type ) : Entity
$type
return Entity
    public static function getEntityInstance($type)
    {
        $types = ['Page', 'Book', 'Chapter'];
        $className = str_replace([' ', '-', '_'], '', ucwords($type));
        if (!in_array($className, $types)) {
            return null;
        }
        return app('BookStack\\' . $className);
    }