Completed
Push — master ( ee97e0...8d3377 )
by mw
199:01 queued 164:02
created

isResourceBuilderFor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace SMW\Exporter\ResourceBuilders;
4
5
use SMW\Exporter\ResourceBuilder;
6
use SMW\DIProperty;
7
use SMWExporter as Exporter;
8
use SMW\DataValueFactory;
9
use SMWDataItem as DataItem;
10
use SMWExpData as ExpData;
11
use SMWExpLiteral as ExpLiteral;
12
13
/**
14
 * @private
15
 *
16
 * @license GNU GPL v2+
17
 * @since 2.5
18
 *
19
 * @author mwjames
20
 */
21
class UniquenessConstraintPropertyValueResourceBuilder extends PropertyValueResourceBuilder {
22
23
	/**
24
	 * @since 2.5
25
	 *
26
	 * {@inheritDoc}
27
	 */
28
	public function isResourceBuilderFor( DIProperty $property ) {
29
		return $property->getKey() === '_PVUC';
30
	}
31
32
	/**
33
	 * @since 2.5
34
	 *
35
	 * {@inheritDoc}
36
	 */
37
	public function addResourceValue( ExpData $expData, DIProperty $property, DataItem $dataItem ) {
38
39
		parent::addResourceValue( $expData, $property, $dataItem );
40
41
		// https://www.w3.org/TR/2004/REC-owl-ref-20040210/#FunctionalProperty-def
42
		//
43
		// "A functional property is a property that can have only one (unique)
44
		// value y for each instance x ..."
45
46
		$expData->addPropertyObjectValue(
47
			$this->exporter->getSpecialNsResource( 'rdf', 'type' ),
0 ignored issues
show
Documentation introduced by
$this->exporter->getSpec...Resource('rdf', 'type') is of type object<SMW\Exporter\Element\ExpNsResource>, but the function expects a object<SMWExpNsResource>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
48
			$this->exporter->getSpecialNsResource( 'owl', 'FunctionalProperty' )
49
		);
50
	}
51
52
}
53