FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DataValues/src/StringValue.php at master · reedy/DataValues · GitHub
reedy
/
DataValues
Public
forked from
DataValues/DataValues
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
DataValues
/
src
/
StringValue.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
92 lines (78 loc) · 2.05 KB
Breadcrumbs
DataValues
/
src
/
StringValue.php
Copy path
File metadata and controls
92 lines (78 loc) · 2.05 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
declare
( strict_types =
1
);
namespace
DataValues
;
class
StringValue
extends
DataValueObject {
/**
* @var string
*/
private
$
value
;
/**
* @param string $value
*
* @throws IllegalValueException
*/
public
function
__construct
(
$
value
) {
if
( !
is_string
(
$
value
) ) {
throw
new
IllegalValueException
(
'
Can only construct StringValue from strings
'
);
}
$
this
->
value
=
$
value
;
}
/**
* @see Serializable::serialize
*
* @return string
*/
public
function
serialize
() {
return
$
this
->
value
;
}
public
function
__serialize
():
array
{
return
[
$
this
->
serialize
() ];
}
/**
* @see Serializable::unserialize
*
* @param string $value
*/
public
function
unserialize
(
$
value
) {
$
this
->
__construct
(
$
value
);
}
public
function
__unserialize
(
array
$
data
):
void
{
$
this
->
unserialize
(
$
data
[
0
] );
}
/**
* @see DataValue::getType
*
* @return string
*/
public
static
function
getType
() {
return
'
string
'
;
}
/**
* Returns the string.
* @see DataValue::getValue
*
* @return string
*/
public
function
getValue
() {
return
$
this
->
value
;
}
/**
* Constructs a new instance from the provided data. Required for {@see DataValueDeserializer}.
* This is expected to round-trip with {@see getArrayValue}.
*
* @deprecated since 1.1. Static DataValue::newFromArray constructors like this are
* underspecified (not in the DataValue interface), and misleadingly named (should be named
* newFromArrayValue). Instead, use DataValue builder callbacks in {@see DataValueDeserializer}.
*
* @param mixed $data Warning! Even if this is expected to be a value as returned by
* {@see getArrayValue}, callers of this specific newFromArray implementation can not guarantee
* this. This is not guaranteed to be a string!
*
* @throws IllegalValueException if $data is not in the expected format. Subclasses of
* InvalidArgumentException are expected and properly handled by {@see DataValueDeserializer}.
* @return self
*/
public
static
function
newFromArray
(
$
data
) {
return
new
static
(
$
data
);
}
}
Back
|
FazBrowse Home
|
New Git URL