Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
27 / 27
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
PersistenceLayerFactory
100.00% covered (success)
100.00%
27 / 27
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 create
100.00% covered (success)
100.00%
27 / 27
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\DoctrineEntityConverter\Factories;
3
4use Apie\Core\BoundedContext\BoundedContextHashmap;
5use Apie\DoctrineEntityConverter\CodeGenerators\AddDoctrineFields;
6use Apie\DoctrineEntityConverter\CodeGenerators\AddSecondLevelCache;
7use Apie\DoctrineEntityConverter\CodeGenerators\LimitFieldLength;
8use Apie\StorageMetadataBuilder\ChainedBootGeneratedCode;
9use Apie\StorageMetadataBuilder\ChainedGeneratedCodeContext;
10use Apie\StorageMetadataBuilder\ChainedPostGeneratedCodeContext;
11use Apie\StorageMetadataBuilder\CodeGenerators\AccessControlListGenerator;
12use Apie\StorageMetadataBuilder\CodeGenerators\AddAutoIdGenerator;
13use Apie\StorageMetadataBuilder\CodeGenerators\AddIndexesCodeGenerator;
14use Apie\StorageMetadataBuilder\CodeGenerators\FileTableGenerator;
15use Apie\StorageMetadataBuilder\CodeGenerators\ItemListCodeGenerator;
16use Apie\StorageMetadataBuilder\CodeGenerators\RootObjectCodeGenerator;
17use Apie\StorageMetadataBuilder\CodeGenerators\SimplePropertiesCodeGenerator;
18use Apie\StorageMetadataBuilder\CodeGenerators\SubObjectCodeGenerator;
19use Apie\StorageMetadataBuilder\Mediators\GeneratedCode;
20use Apie\StorageMetadataBuilder\StorageMetadataBuilder;
21
22final class PersistenceLayerFactory
23{
24    public function create(BoundedContextHashmap $boundedContextHashmap, bool $singleIndexTable = true): GeneratedCode
25    {
26        $simple = new SimplePropertiesCodeGenerator();
27        $indexer = new AddIndexesCodeGenerator($singleIndexTable);
28        $acl = new AccessControlListGenerator();
29        $testItem = new StorageMetadataBuilder(
30            $boundedContextHashmap,
31            new ChainedBootGeneratedCode(
32                $simple,
33                $indexer,
34                $acl,
35            ),
36            new ChainedGeneratedCodeContext(
37                new AddAutoIdGenerator(),
38                new FileTableGenerator(),
39                new SubObjectCodeGenerator(),
40                new ItemListCodeGenerator(),
41                $simple,
42                new RootObjectCodeGenerator()
43            ),
44            new ChainedPostGeneratedCodeContext(
45                $indexer,
46                $acl,
47                new AddDoctrineFields(),
48                new LimitFieldLength(),
49                new AddSecondLevelCache(),
50            )
51        );
52        return $testItem->generateCode();
53    }
54}