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
2declare( strict_types=1 );
3
4/**
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22namespace Wikimedia\Parsoid\Utils;
23
24use Wikimedia\JsonCodec\Hint;
25use Wikimedia\JsonCodec\JsonCodecable;
26use Wikimedia\Parsoid\DOM\DocumentFragment;
27
28/**
29 * This is an extension of JsonCodecable which adds some properties useful
30 * for rich attributes:
31 * * a `::flatten()` method which provides a plain string form of the data
32 *   which is used for compatibility with HTML semantics, and
33 * * a `::hint()` method which is used to provide additional class hint
34 *   information for object.  The default class hint is the name of the
35 *   class, but if you want to add modifiers, or perhaps use a superclass
36 *   as a hint, this method will allow that sort of customization.
37 */
38interface RichCodecable extends JsonCodecable {
39
40    /**
41     * Provide a constructor for a default value for objects of this type.
42     * @return ?self
43     */
44    public static function defaultValue(): ?self;
45
46    /**
47     * Provide a JsonCodec `Hint` for serializing objects of this type.
48     * @return class-string|Hint|null
49     */
50    public static function hint();
51
52    /**
53     * Provide a flattened "plain string" form of this data for use
54     * as the value of a compatibility attribute to implement HTML
55     * semantics.
56     *
57     * @return ?string a plain string, or null to omit the compatibility
58     *  attribute
59     */
60    public function flatten(): ?string;
61
62    /**
63     * Iterate over any DocumentFragments embedded in this attribute.
64     * @return \Iterator<DocumentFragment>
65     */
66    public function embeddedDocumentFragments(): \Iterator;
67}