| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <[email protected]> |
| 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 | * @author Jordi Boggiano <[email protected]> |
| 18 | */ |
| 19 | interface DecoderInterface |
| 20 | { |
| 21 | /** |
| 22 | * Decodes a string into PHP data. |
| 23 | * |
| 24 | * @param string $data Data to decode |
| 25 | * @param string $format Format name |
| 26 | * @param array $context Options that decoders have access to |
| 27 | * |
| 28 | * The format parameter specifies which format the data is in; valid values |
| 29 | * depend on the specific implementation. Authors implementing this interface |
| 30 | * are encouraged to document which formats they support in a non-inherited |
| 31 | * phpdoc comment. |
| 32 | * |
| 33 | * @throws UnexpectedValueException |
| 34 | */ |
| 35 | public function decode(string $data, string $format, array $context = []): mixed; |
| 36 | |
| 37 | /** |
| 38 | * Checks whether the deserializer can decode from given format. |
| 39 | * |
| 40 | * @param string $format Format name |
| 41 | */ |
| 42 | public function supportsDecoding(string $format): bool; |
| 43 | } |