1 | <?php |
||
13 | class MultilingualTextValue extends DataValueObject { |
||
|
|||
14 | |||
15 | /** |
||
16 | * Array with language codes pointing to their associated texts. |
||
17 | * |
||
18 | * @var MonolingualTextValue[] |
||
19 | */ |
||
20 | private $texts = []; |
||
21 | |||
22 | /** |
||
23 | * @param MonolingualTextValue[] $monolingualValues |
||
24 | * |
||
25 | * @throws IllegalValueException |
||
26 | */ |
||
27 | 40 | public function __construct( array $monolingualValues ) { |
|
42 | |||
43 | /** |
||
44 | * @see Serializable::serialize |
||
45 | * |
||
46 | * @return string |
||
47 | */ |
||
48 | 15 | public function serialize() { |
|
51 | |||
52 | /** |
||
53 | * @see Serializable::unserialize |
||
54 | * |
||
55 | * @param string $value |
||
56 | */ |
||
57 | 15 | public function unserialize( $value ) { |
|
60 | |||
61 | /** |
||
62 | * @see DataValue::getType |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | 10 | public static function getType() { |
|
69 | |||
70 | /** |
||
71 | * Returns the texts as an array of monolingual text values, |
||
72 | * with the language codes as array keys. |
||
73 | * |
||
74 | * @return MonolingualTextValue[] |
||
75 | 3 | */ |
|
76 | 3 | public function getTexts() { |
|
79 | |||
80 | /** |
||
81 | * Returns the multilingual text value |
||
82 | * @see DataValue::getValue |
||
83 | * |
||
84 | * @return self |
||
85 | 5 | */ |
|
86 | 5 | public function getValue() { |
|
89 | |||
90 | /** |
||
91 | * @see DataValue::getArrayValue |
||
92 | * |
||
93 | * @return mixed |
||
94 | */ |
||
95 | 10 | public function getArrayValue() { |
|
107 | |||
108 | /** |
||
109 | * Constructs a new instance from the provided data. Required for @see DataValueDeserializer. |
||
110 | 11 | * This is expected to round-trip with @see getArrayValue. |
|
111 | 9 | * |
|
112 | * @deprecated since 1.0.0. Static DataValue::newFromArray constructors like this are |
||
113 | * underspecified (not in the DataValue interface), and misleadingly named (should be named |
||
114 | 11 | * newFromArrayValue). Instead, use DataValue builder callbacks in @see DataValueDeserializer. |
|
115 | * |
||
116 | * @param mixed $data Warning! Even if this is expected to be a value as returned by |
||
117 | * @see getArrayValue, callers of this specific newFromArray implementation can not guarantee |
||
118 | * this. This is not even guaranteed to be an array! |
||
119 | * |
||
120 | * @throws IllegalValueException if $data is not in the expected format. Subclasses of |
||
121 | * InvalidArgumentException are expected and properly handled by @see DataValueDeserializer. |
||
122 | * @return self |
||
123 | */ |
||
124 | public static function newFromArray( $data ) { |
||
137 | |||
138 | } |
||
139 |