-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDefinitionContentFactory.php
More file actions
62 lines (50 loc) · 2.16 KB
/
DefinitionContentFactory.php
File metadata and controls
62 lines (50 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
declare(strict_types=1);
namespace Picamator\TransferObject\DefinitionGenerator\Content;
use Picamator\TransferObject\DefinitionGenerator\Content\Builder\ContentBuilder;
use Picamator\TransferObject\DefinitionGenerator\Content\Builder\ContentBuilderInterface;
use Picamator\TransferObject\DefinitionGenerator\Content\Expander\BuilderExpanderInterface;
use Picamator\TransferObject\DefinitionGenerator\Content\Expander\BuildInTypeBuilderExpander;
use Picamator\TransferObject\DefinitionGenerator\Content\Expander\CollectionTypeBuilderExpander;
use Picamator\TransferObject\DefinitionGenerator\Content\Expander\TransferTypeBuilderExpander;
use Picamator\TransferObject\DefinitionGenerator\Content\Reader\ContentReader;
use Picamator\TransferObject\DefinitionGenerator\Content\Reader\ContentReaderInterface;
use Picamator\TransferObject\Shared\CachedFactoryTrait;
class DefinitionContentFactory
{
use CachedFactoryTrait;
public function createContentReader(): ContentReaderInterface
{
return $this->getCached(
key: 'definition-builder',
factory: fn (): ContentReaderInterface => new ContentReader(
$this->createContentBuilder(),
$this->createBuilderExpander(),
),
);
}
protected function createContentBuilder(): ContentBuilderInterface
{
return new ContentBuilder();
}
protected function createBuilderExpander(): BuilderExpanderInterface
{
$builderExpander = $this->createTransferTypeBuilderExpander();
$builderExpander
->setNextExpander($this->createCollectionTypeBuilderExpander())
->setNextExpander($this->createBuildInTypeBuilderExpander());
return $builderExpander;
}
protected function createBuildInTypeBuilderExpander(): BuilderExpanderInterface
{
return new BuildInTypeBuilderExpander();
}
protected function createCollectionTypeBuilderExpander(): BuilderExpanderInterface
{
return new CollectionTypeBuilderExpander();
}
protected function createTransferTypeBuilderExpander(): BuilderExpanderInterface
{
return new TransferTypeBuilderExpander();
}
}