Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3namespace Automattic\Jetpack\Schema;
4
5/**
6 * The Parser interface defines the contract for schema type classes.
7 *
8 * Each schema type class implementing this interface should provide a parse
9 * method to handle converting the input value to the correct data type.
10 *
11 * The purpose of the interface is to provide a consistent way to work with
12 * different schema types, ensuring that all schema type classes have a common
13 * method to perform the necessary data handling.
14 */
15interface Parser extends \JsonSerializable {
16    /**
17     * The parse method t is responsible for parsing input value.
18     *
19     * If the input value is valid, the method should return the parsed value.
20     * If the input value is invalid, the method should return a default value.
21     * or throw an exception, depending on the implementation.
22     *
23     * @param mixed          $value   The input value to be parsed.
24     * @param Schema_Context $context Schema validation metadata.
25     *
26     * @return mixed The parsed value.
27     * @throws \RuntimeException If the input value is invalid.
28     */
29    public function parse( $value, $context );
30
31    /**
32     * The describe method is responsible for returning a description of the schema.
33     *
34     * @return array
35     */
36    public function schema();
37
38    /**
39     * The __toString method is responsible for returning a string representation of the schema.
40     *
41     * @return string
42     */
43    public function __toString();
44}