-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path06.cache.php
42 lines (34 loc) · 917 Bytes
/
06.cache.php
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
<?php
declare(strict_types=1);
use TypeLang\Mapper\Mapper;
require __DIR__ . '/../../vendor/autoload.php';
class ExampleDTO
{
/**
* @param int<0, max> $value
*/
public function __construct(
public readonly int $value = 0,
) {}
}
$cache = new \Symfony\Component\Cache\Psr16Cache(
pool: new \Symfony\Component\Cache\Adapter\FilesystemAdapter(
namespace: 'typelang',
directory: __DIR__ . '/../../var/cache',
),
);
$platform = new \TypeLang\Mapper\Platform\StandardPlatform(
driver: new \TypeLang\Mapper\Mapping\Driver\Psr16CachedDriver(
cache: $cache,
delegate: new \TypeLang\Mapper\Mapping\Driver\DocBlockDriver(
delegate: new \TypeLang\Mapper\Mapping\Driver\AttributeDriver(),
),
),
);
$mapper = new Mapper($platform);
var_dump($mapper->normalize(new ExampleDTO(42)));
//
// array:1 [
// "value" => 42
// ]
//