1 | <?php |
||
22 | class Berlin { |
||
23 | |||
24 | /** |
||
25 | * @var Germany |
||
26 | */ |
||
27 | private $germany; |
||
28 | |||
29 | /** |
||
30 | * @var City |
||
31 | */ |
||
32 | private $city; |
||
33 | |||
34 | /** |
||
35 | * @var CountryProperty |
||
36 | */ |
||
37 | private $country; |
||
38 | |||
39 | /** |
||
40 | * @var InstanceOfProperty |
||
41 | */ |
||
42 | private $instanceOf; |
||
43 | |||
44 | /** |
||
45 | * @var PostalCodeProperty |
||
46 | */ |
||
47 | private $postCode; |
||
48 | |||
49 | 1 | public function __construct() { |
|
57 | |||
58 | 1 | public function newItem() { |
|
59 | 1 | $item = new Item( new ItemId( 'Q64' ) ); |
|
60 | |||
61 | 1 | $item->setFingerprint( $this->newFingerprint() ); |
|
62 | 1 | $item->setStatements( $this->newStatements() ); |
|
63 | 1 | $item->setSiteLinkList( $this->newSiteLinkList() ); |
|
64 | |||
65 | 1 | return $item; |
|
66 | } |
||
67 | |||
68 | 1 | public function newFingerprint() { |
|
69 | 1 | $fingerprint = new Fingerprint(); |
|
70 | |||
71 | 1 | $fingerprint->setLabel( 'en', 'Berlin' ); |
|
72 | 1 | $fingerprint->setLabel( 'de', 'Berlin' ); |
|
73 | 1 | $fingerprint->setLabel( 'nl', 'Berlijn' ); |
|
74 | |||
75 | 1 | $fingerprint->setDescription( 'en', 'capital city and state of Germany' ); |
|
76 | 1 | $fingerprint->setDescription( 'de', 'Hauptstadt von Deutschland' ); |
|
77 | |||
78 | 1 | return $fingerprint; |
|
79 | } |
||
80 | |||
81 | 1 | public function newSiteLinkList() { |
|
82 | 1 | $links = new SiteLinkList(); |
|
83 | |||
84 | 1 | $links->addNewSiteLink( 'enwiki', 'Berlin' ); |
|
85 | 1 | $links->addNewSiteLink( 'nlwiki', 'Berlijn' ); |
|
86 | |||
87 | 1 | return $links; |
|
88 | } |
||
89 | |||
90 | 1 | public function newStatements() { |
|
91 | 1 | $statements = new StatementList(); |
|
92 | |||
93 | 1 | $statements->addNewStatement( |
|
94 | 1 | new PropertyValueSnak( |
|
95 | 1 | $this->country->newPropertyId(), |
|
96 | 1 | new EntityIdValue( $this->germany->newItemId() ) |
|
97 | 1 | ), |
|
98 | 1 | null, |
|
99 | 1 | null, |
|
100 | 'first guid' |
||
101 | 1 | ); |
|
102 | |||
103 | 1 | $statements->addNewStatement( |
|
104 | 1 | new PropertyValueSnak( |
|
105 | 1 | $this->instanceOf->newPropertyId(), |
|
106 | 1 | new EntityIdValue( $this->city->newItemId() ) |
|
107 | 1 | ), |
|
108 | 1 | null, |
|
109 | 1 | null, |
|
110 | 'second guid' |
||
111 | 1 | ); |
|
112 | |||
113 | 1 | $statements->addNewStatement( |
|
114 | 1 | new PropertyValueSnak( |
|
115 | 1 | $this->postCode->newPropertyId(), |
|
116 | 1 | new StringValue( '10115–14199' ) |
|
117 | 1 | ), |
|
118 | 1 | null, |
|
119 | 1 | null, |
|
120 | 'third guid' |
||
121 | 1 | ); |
|
122 | |||
123 | 1 | return $statements; |
|
124 | } |
||
125 | |||
126 | /** |
||
127 | * @return Item[] |
||
128 | */ |
||
129 | public function getItemDependencies() { |
||
135 | |||
136 | /** |
||
137 | * @return Property[] |
||
138 | */ |
||
139 | public function getPropertyDependencies() { |
||
145 | |||
146 | } |
||
147 |