<?php

class LdapPreviewFactory
{

    const User = 'User';
    const Addresses = 'Addresses';

    public static function generateImporterOfType($ldapInterface)
    {
        if ($ldapInterface->connectedModel === LdapPreviewFactory::User) {
            $preview = new LdapUserPreview($ldapInterface);
        } elseif ($ldapInterface->connectedModel === LdapPreviewFactory::Addresses) {
            $preview = new LdapAddressPreview($ldapInterface);
        } else {
            throw new CHttpException(404, 'Invalid request. Object type does not exist.');
        }

        return $preview;
    }
}
