Skip to content

Latest commit

 

History

History
39 lines (25 loc) · 803 Bytes

EncoderFactory.md

File metadata and controls

39 lines (25 loc) · 803 Bytes

EncoderFactory

without name (default)

<?php

use Chubbyphp\Serialization\Encoder\TypeEncoderInterface;
use Chubbyphp\Serialization\ServiceFactory\EncoderFactory;
use Psr\Container\ContainerInterface;

/** @var ContainerInterface $container */
$container = ...;

// $container->get(TypeEncoderInterface::class.'[]')

$factory = new EncoderFactory();

$encoder = $factory($container);

with name default

<?php

use Chubbyphp\Serialization\Encoder\TypeEncoderInterface;
use Chubbyphp\Serialization\ServiceFactory\EncoderFactory;
use Psr\Container\ContainerInterface;

/** @var ContainerInterface $container */
$container = ...;

// $container->get(TypeEncoderInterface::class.'[]default')

$factory = [EncoderFactory::class, 'default'];

$encoder = $factory($container);