<?php

/**
 * Lifestyle Webconsulting GmbH
 *
 * LICENSE: This Software is the property of Lifestyle Webconsulting GmbH (Aschaffenburg, Germany)
 * and is private by copyright law - it is NOT Freeware.
 *
 * Any unauthorized use of this software without a valid license
 * is a violation of the license agreement and will be prosecuted by
 * civil and criminal law.
 *
 * @copyright  2018 Lifestyle Webconsulting GmbH
 * @link       http://www.life-style.de
 */

namespace Sso\Tools\UserIdentifierBundle\Api;

use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface as Container;
use Sso\Tools\UserIdentifierBundle\Model\Factory as ModelFactory;

/**
 * Api manager
 */
class Manager
{

    /**
     * Symfony container
     *
     * @var Container
     */
    private $container;

    /**
     * List of objects
     *
     * @var array
     */
    private $factory = array();

    /**
     * Constructor
     *
     * @param Container $container
     */
    public function __construct(Container $container)
    {
        $this->container = $container;
    }

    /**
     * The logger
     *
     * @return LoggerInterface
     */
    public function logger()
    {
        return $this->container->get('logger');
    }

    /**
     * @return ModelFactory
     */
    public function modelFactory()
    {
        return isset($this->factory[__FUNCTION__]) ? $this->factory[__FUNCTION__] : ($this->factory[__FUNCTION__] = new ModelFactory($this->serializer()));
    }

    /**
     * @return \Guzzle\Service\Client
     */
    public function client()
    {
        return $this->container->get('sso_tools_user_identifier.api_client');
    }

    /**
     * @return \JMS\Serializer\Serializer
     */
    public function serializer()
    {
        return $this->container->get('jms_serializer');
    }

}