<?php

class ThirdPartyConnectorFactory
{

    const XING = 'XING';
    const ICLOUD = 'iCloud';
    const GOOGLE = 'Google';

    public static function generateCredentialControllerOfType($provider)
    {
        if ($provider === ThirdPartyConnectorFactory::XING) {
            $providerController = new XingConnector(ThirdPartyConnectorFactory::XING);
        } elseif ($provider === ThirdPartyConnectorFactory::GOOGLE) {
            $providerController = new GoogleConnector(ThirdPartyConnectorFactory::GOOGLE);
        } elseif ($provider === ThirdPartyConnectorFactory::ICLOUD) {
            $providerController = new iContactsConnector(ThirdPartyConnectorFactory::ICLOUD);
        } else {
            throw new CHttpException(404, 'Invalid request. Object type does not exist.');
        }

        return $providerController;
    }
}
