-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathHateoas.php
55 lines (45 loc) · 1.25 KB
/
Hateoas.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
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
declare(strict_types=1);
namespace Hateoas;
use Hateoas\Helper\LinkHelper;
use JMS\Serializer\DeserializationContext;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerInterface;
class Hateoas implements SerializerInterface
{
/**
* @var SerializerInterface
*/
private $serializer;
/**
* @var LinkHelper
*/
private $linkHelper;
public function __construct(SerializerInterface $serializer, LinkHelper $linkHelper)
{
$this->serializer = $serializer;
$this->linkHelper = $linkHelper;
}
/**
* {@inheritDoc}
*/
public function serialize($data, string $format, ?SerializationContext $context = null, ?string $type = null): string
{
return $this->serializer->serialize($data, $format, $context, $type);
}
/**
* {@inheritDoc}
*/
public function deserialize(string $data, string $type, string $format, ?DeserializationContext $context = null)
{
return $this->serializer->deserialize($data, $type, $format, $context);
}
public function getSerializer(): SerializerInterface
{
return $this->serializer;
}
public function getLinkHelper(): LinkHelper
{
return $this->linkHelper;
}
}