alltube/classes/Factory/LocaleManagerFactory.php

31 lines
637 B
PHP
Raw Normal View History

<?php
2020-10-20 21:29:50 +00:00
namespace Alltube\Factory;
use Alltube\Exception\DependencyException;
2020-10-20 21:29:50 +00:00
use Alltube\LocaleManager;
2021-10-18 11:16:28 +00:00
use Locale;
use Slim\Container;
/**
* Class LocaleManagerFactory
* @package Alltube
*/
class LocaleManagerFactory
{
/**
* @param Container $container
2020-12-17 21:43:05 +00:00
* @return LocaleManager
* @throws DependencyException
*/
2020-12-17 21:43:05 +00:00
public static function create(Container $container): LocaleManager
{
2021-10-18 11:16:28 +00:00
if (!class_exists(Locale::class)) {
throw new DependencyException('You need to install the intl extension for PHP.');
}
return new LocaleManager($container->get('session'));
}
}