-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathPropertyValueSnak.php
More file actions
88 lines (77 loc) · 1.81 KB
/
PropertyValueSnak.php
File metadata and controls
88 lines (77 loc) · 1.81 KB
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
<?php
namespace Wikibase\DataModel\Snak;
use DataValues\DataValue;
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\PropertyId;
/**
* Class representing a property value snak.
* See https://www.mediawiki.org/wiki/Wikibase/DataModel#PropertyValueSnak
*
* @since 0.1
*
* @license GPL-2.0+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
* @author Daniel Kinzler
*/
class PropertyValueSnak extends SnakObject {
protected $dataValue;
/**
* Support for passing in an EntityId instance that is not a PropertyId instance has
* been deprecated since 0.5.
*
* @since 0.1
*
* @param PropertyId|EntityId|int $propertyId
* @param DataValue $dataValue
*/
public function __construct( $propertyId, DataValue $dataValue ) {
parent::__construct( $propertyId );
$this->dataValue = $dataValue;
}
/**
* Returns the value of the property value snak.
*
* @since 0.1
*
* @return DataValue
*/
public function getDataValue() {
return $this->dataValue;
}
/**
* @see Serializable::serialize
*
* @since 7.0 serialization format changed in an incompatible way
*
* @return string
*/
public function serialize() {
return serialize( [ $this->propertyId->getSerialization(), $this->dataValue ] );
}
/**
* @see Serializable::unserialize
*
* @since 0.1
*
* @param string $serialized
*/
public function unserialize( $serialized ) {
list( $propertyId, $this->dataValue ) = unserialize( $serialized );
if ( is_string( $propertyId ) ) {
$this->propertyId = new PropertyId( $propertyId );
} else {
// Backwards compatibility with the previous serialization format
$this->propertyId = PropertyId::newFromNumber( $propertyId );
}
}
/**
* @see Snak::getType
*
* @since 0.2
*
* @return string
*/
public function getType() {
return 'value';
}
}