*/ namespace oat\taoItems\model\pack; use oat\taoItems\model\pack\encoders\Encoding; use ReflectionClass; use tao_models_classes_Service; /** * Class EncoderService * Factory retrieve encoder by his name * @package oat\taoItems\model\pack */ class EncoderService extends tao_models_classes_Service { /** * @param $type * * @return Encoding * @throws ExceptionMissingEncoder */ public function get($type) { $class = __NAMESPACE__ . '\\encoders\\' . ucfirst($type) . 'Encoder'; if ( class_exists($class) && in_array( 'oat\taoItems\model\pack\encoders\Encoding', class_implements($class) ) ) { return (new ReflectionClass($class))->newInstanceArgs(array_slice(func_get_args(), 1, func_num_args())); } throw new ExceptionMissingEncoder('Encoder missing : ' . $class); } }