|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
namespace Symfony\Component\Serializer; |
|
|
4 |
|
|
|
5 |
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; |
|
|
6 |
use Symfony\Component\Serializer\Encoder\EncoderInterface; |
|
|
7 |
use Symfony\Component\Serializer\Encoder\DecoderInterface; |
|
|
8 |
use Symfony\Component\Serializer\Encoder\NormalizationAwareInterface; |
|
|
9 |
|
|
|
10 |
/* |
|
|
11 |
* This file is part of the Symfony framework. |
|
|
12 |
* |
|
|
13 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
14 |
* |
|
|
15 |
* This source file is subject to the MIT license that is bundled |
|
|
16 |
* with this source code in the file LICENSE. |
|
|
17 |
*/ |
|
|
18 |
|
|
|
19 |
/** |
|
|
20 |
* Defines the interface of the Serializer |
|
|
21 |
* |
|
|
22 |
* @author Jordi Boggiano <j.boggiano@seld.be> |
|
|
23 |
*/ |
|
|
24 |
interface SerializerInterface |
|
|
25 |
{ |
|
|
26 |
/** |
|
|
27 |
* Serializes data in the appropriate format |
|
|
28 |
* |
|
|
29 |
* @param mixed $data any data |
|
|
30 |
* @param string $format format name |
|
|
31 |
* @return string |
|
|
32 |
*/ |
|
|
33 |
function serialize($data, $format); |
|
|
34 |
|
|
|
35 |
/** |
|
|
36 |
* Deserializes data into the given type. |
|
|
37 |
* |
|
|
38 |
* @param mixed $data |
|
|
39 |
* @param string $type |
|
|
40 |
* @param string $format |
|
|
41 |
*/ |
|
|
42 |
function deserialize($data, $type, $format); |
|
|
43 |
|
|
|
44 |
/** |
|
|
45 |
* Normalizes any data into a set of arrays/scalars |
|
|
46 |
* |
|
|
47 |
* @param mixed $data data to normalize |
|
|
48 |
* @param string $format format name, present to give the option to normalizers to act differently based on formats |
|
|
49 |
* @return array|scalar |
|
|
50 |
*/ |
|
|
51 |
function normalize($data, $format = null); |
|
|
52 |
|
|
|
53 |
/** |
|
|
54 |
* Denormalizes data into the given type. |
|
|
55 |
* |
|
|
56 |
* @param mixed $data |
|
|
57 |
* @param string $type |
|
|
58 |
* @param string $format |
|
|
59 |
* @return mixed |
|
|
60 |
*/ |
|
|
61 |
function denormalize($data, $type, $format = null); |
|
|
62 |
|
|
|
63 |
/** |
|
|
64 |
* Encodes data into the given format |
|
|
65 |
* |
|
|
66 |
* @param mixed $data data to encode |
|
|
67 |
* @param string $format format name |
|
|
68 |
* @return array|scalar |
|
|
69 |
*/ |
|
|
70 |
function encode($data, $format); |
|
|
71 |
|
|
|
72 |
/** |
|
|
73 |
* Decodes a string from the given format back into PHP data |
|
|
74 |
* |
|
|
75 |
* @param string $data data to decode |
|
|
76 |
* @param string $format format name |
|
|
77 |
* @return mixed |
|
|
78 |
*/ |
|
|
79 |
function decode($data, $format); |
|
|
80 |
|
|
|
81 |
/** |
|
|
82 |
* Checks whether the serializer can serialize to given format |
|
|
83 |
* |
|
|
84 |
* @param string $format format name |
|
|
85 |
* @return Boolean |
|
|
86 |
*/ |
|
|
87 |
function supportsSerialization($format); |
|
|
88 |
|
|
|
89 |
/** |
|
|
90 |
* Checks whether the serializer can deserialize from given format |
|
|
91 |
* |
|
|
92 |
* @param string $format format name |
|
|
93 |
* @return Boolean |
|
|
94 |
*/ |
|
|
95 |
function supportsDeserialization($format); |
|
|
96 |
|
|
|
97 |
/** |
|
|
98 |
* Checks whether the serializer can encode to given format |
|
|
99 |
* |
|
|
100 |
* @param string $format format name |
|
|
101 |
* @return Boolean |
|
|
102 |
*/ |
|
|
103 |
function supportsEncoding($format); |
|
|
104 |
|
|
|
105 |
/** |
|
|
106 |
* Checks whether the serializer can decode from given format |
|
|
107 |
* |
|
|
108 |
* @param string $format format name |
|
|
109 |
* @return Boolean |
|
|
110 |
*/ |
|
|
111 |
function supportsDecoding($format); |
|
|
112 |
|
|
|
113 |
/** |
|
|
114 |
* Get the encoder for the given format |
|
|
115 |
* |
|
|
116 |
* @return EncoderInterface |
|
|
117 |
*/ |
|
|
118 |
function getEncoder($format); |
|
|
119 |
} |