Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DenormalizationFieldMappingFactoryFactory
- Loading branch information
1 parent
615c6a7
commit 668a07f
Showing
9 changed files
with
131 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ | |
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "4.0-dev" | ||
"dev-master": "4.1-dev" | ||
} | ||
}, | ||
"scripts": { | ||
|
39 changes: 39 additions & 0 deletions
39
doc/ServiceFactory/DenormalizationFieldMappingFactoryFactory.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# DenormalizationFieldMappingFactoryFactory | ||
|
||
## without name (default) | ||
|
||
```php | ||
<?php | ||
|
||
use Chubbyphp\Deserialization\Decoder\TypeDecoderInterface; | ||
use Chubbyphp\Deserialization\ServiceFactory\DenormalizationFieldMappingFactoryFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @var ContainerInterface $container */ | ||
$container = ...; | ||
|
||
// $container->get(TypeDecoderInterface::class.'[]') | ||
|
||
$factory = new DenormalizationFieldMappingFactoryFactory(); | ||
|
||
$decoder = $factory($container); | ||
``` | ||
|
||
## with name `default` | ||
|
||
```php | ||
<?php | ||
|
||
use Chubbyphp\Deserialization\Decoder\TypeDecoderInterface; | ||
use Chubbyphp\Deserialization\ServiceFactory\DenormalizationFieldMappingFactoryFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @var ContainerInterface $container */ | ||
$container = ...; | ||
|
||
// $container->get(TypeDecoderInterface::class.'[]default') | ||
|
||
$factory = [DenormalizationFieldMappingFactoryFactory::class, 'default']; | ||
|
||
$decoder = $factory($container); | ||
``` |
18 changes: 18 additions & 0 deletions
18
src/ServiceFactory/DenormalizationFieldMappingFactoryFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Deserialization\ServiceFactory; | ||
|
||
use Chubbyphp\Deserialization\Mapping\DenormalizationFieldMappingFactory; | ||
use Chubbyphp\Deserialization\Mapping\DenormalizationFieldMappingFactoryInterface; | ||
use Chubbyphp\Laminas\Config\Factory\AbstractFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class DenormalizationFieldMappingFactoryFactory extends AbstractFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DenormalizationFieldMappingFactoryInterface | ||
{ | ||
return new DenormalizationFieldMappingFactory(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
tests/Unit/ServiceFactory/DenormalizationFieldMappingFactoryFactoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Tests\Deserialization\Unit\ServiceFactory; | ||
|
||
use Chubbyphp\Deserialization\Mapping\DenormalizationFieldMappingFactoryInterface; | ||
use Chubbyphp\Deserialization\ServiceFactory\DenormalizationFieldMappingFactoryFactory; | ||
use Chubbyphp\Mock\MockByCallsTrait; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** | ||
* @covers \Chubbyphp\Deserialization\ServiceFactory\DenormalizationFieldMappingFactoryFactory | ||
* | ||
* @internal | ||
*/ | ||
final class DenormalizationFieldMappingFactoryFactoryTest extends TestCase | ||
{ | ||
use MockByCallsTrait; | ||
|
||
public function testInvoke(): void | ||
{ | ||
/** @var ContainerInterface $container */ | ||
$container = $this->getMockByCalls(ContainerInterface::class, []); | ||
|
||
$factory = new DenormalizationFieldMappingFactoryFactory(); | ||
|
||
$service = $factory($container); | ||
|
||
self::assertInstanceOf(DenormalizationFieldMappingFactoryInterface::class, $service); | ||
} | ||
|
||
public function testCallStatic(): void | ||
{ | ||
/** @var ContainerInterface $container */ | ||
$container = $this->getMockByCalls(ContainerInterface::class, []); | ||
|
||
$factory = [DenormalizationFieldMappingFactoryFactory::class, 'default']; | ||
|
||
$service = $factory($container); | ||
|
||
self::assertInstanceOf(DenormalizationFieldMappingFactoryInterface::class, $service); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters