Code Duplication    Length = 12-24 lines in 2 locations

src/Item.php 2 locations

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