/
DataFieldData.php
46 lines (38 loc) · 996 Bytes
/
DataFieldData.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
<?php
namespace Concrete\Core\Summary\Data\Field;
use Symfony\Component\Serializer\Normalizer\DenormalizableInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class DataFieldData implements DataFieldDataInterface
{
/**
* @var int|float|string|bool
*/
protected $data;
public function __construct($data = null)
{
$this->data = $data;
}
/**
* @param bool|float|int|string $data
*/
public function setData($data): void
{
$this->data = $data;
}
public function __toString()
{
return (string) $this->data;
}
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [
'class' => self::class,
'data' => (string) $this->data
];
}
public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null, array $context = [])
{
$this->setData($data['data']);
}
}