Code Duplication    Length = 12-24 lines in 2 locations

src/Item.php 2 locations

@@ 136-159 (lines=24) @@
133
	 * @param string $propertyId
134
	 * @return bool|Time[]
135
	 */
136
	protected function getPropertyOfTypeTime( $propertyId ) {
137
		$times = [];
138
		$entity = $this->getEntity();
139
		if ( !isset( $entity['claims'][$propertyId] ) ) {
140
			// No statements for this property.
141
			return $times;
142
		}
143
		// print_r($entity['claims'][$propertyId]);exit();
144
		foreach ( $entity['claims'][$propertyId] as $claim ) {
145
			// print_r($claim);
146
			$times[] = new Time( $claim, $this->lang, $this->cache );
147
//
148
// $timeValue = $claim['datavalue']['value']['time'];
149
// // Ugly workaround for imprecise dates. :-(
150
// if (preg_match('/([0-9]{1,4})-00-00/', $timeValue, $matches) === 1) {
151
// $timeValue = $matches[1];
152
// return $timeValue;
153
// }
154
// $time = strtotime($timeValue);
155
// return date($dateFormat, $time);
156
			// }
157
		}
158
		return $times;
159
	}
160
161
	/**
162
	 * Get the Item that is referred to by the specified item's property.
@@ 169-180 (lines=12) @@
166
	 *
167
	 * @return \Samwilson\SimpleWikidata\Properties\Item[]
168
	 */
169
	protected function getPropertyOfTypeItem( $propertyId ) {
170
		$entity = $this->getEntity( $this->id );
171
		if ( !isset( $entity['claims'][$propertyId] ) ) {
172
			return [];
173
		}
174
		$items = [];
175
		foreach ( $entity['claims'][$propertyId] as $claim ) {
176
			$items[] = new Properties\Item( $claim, $this->lang, $this->cache );
177
		}
178
179
		return $items;
180
	}
181
182
	public function setPropertyOfTypeItem( $property, $itemId ) {
183
		$itemIdNumeric = substr( $itemId, 1 );