05e9b2789b170103dabbabead7803263621ca1fe
[yaffs-website] / vendor / symfony / serializer / Encoder / EncoderInterface.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Serializer\Encoder;
13
14 use Symfony\Component\Serializer\Exception\UnexpectedValueException;
15
16 /**
17  * Defines the interface of encoders.
18  *
19  * @author Jordi Boggiano <j.boggiano@seld.be>
20  */
21 interface EncoderInterface
22 {
23     /**
24      * Encodes data into the given format.
25      *
26      * @param mixed  $data    Data to encode
27      * @param string $format  Format name
28      * @param array  $context options that normalizers/encoders have access to
29      *
30      * @return scalar
31      *
32      * @throws UnexpectedValueException
33      */
34     public function encode($data, $format, array $context = array());
35
36     /**
37      * Checks whether the serializer can encode to given format.
38      *
39      * @param string $format format name
40      *
41      * @return bool
42      */
43     public function supportsEncoding($format);
44 }