summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/Query/ProfileAnnotators/DurationProfileAnnotator.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/src/Query/ProfileAnnotators/DurationProfileAnnotator.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/src/Query/ProfileAnnotators/DurationProfileAnnotator.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/src/Query/ProfileAnnotators/DurationProfileAnnotator.php b/www/wiki/extensions/SemanticMediaWiki/src/Query/ProfileAnnotators/DurationProfileAnnotator.php
new file mode 100644
index 00000000..cf237c23
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/src/Query/ProfileAnnotators/DurationProfileAnnotator.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace SMW\Query\ProfileAnnotators;
+
+use SMW\DIProperty;
+use SMW\Query\ProfileAnnotator;
+use SMWDINumber as DINumber;
+
+/**
+ * @license GNU GPL v2+
+ * @since 1.9
+ *
+ * @author mwjames
+ */
+class DurationProfileAnnotator extends ProfileAnnotatorDecorator {
+
+ /**
+ * @var integer
+ */
+ private $duration;
+
+ /**
+ * @since 1.9
+ *
+ * @param ProfileAnnotator $profileAnnotator
+ * @param integer $duration
+ */
+ public function __construct( ProfileAnnotator $profileAnnotator, $duration ) {
+ parent::__construct( $profileAnnotator );
+ $this->duration = $duration;
+ }
+
+ /**
+ * ProfileAnnotatorDecorator::addPropertyValues
+ */
+ protected function addPropertyValues() {
+ if ( $this->duration > 0 ) {
+ $this->addGreaterThanZeroQueryDuration( $this->duration );
+ }
+ }
+
+ private function addGreaterThanZeroQueryDuration( $duration ) {
+ $this->getSemanticData()->addPropertyObjectValue(
+ new DIProperty( '_ASKDU' ),
+ new DINumber( $duration )
+ );
+ }
+
+}