summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-17 09:15:42 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-17 09:44:51 +0100
commita1789ddde42033f1b05cc4929491214ee6e79383 (patch)
tree63615735c4ddffaaabf2428946bb26f90899f7bf /vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php
parent9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff)
Update to MediaWiki 1.26.0
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php97
1 files changed, 97 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php
new file mode 100644
index 00000000..00f21e44
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php
@@ -0,0 +1,97 @@
+<?php
+namespace Elastica\Suggest;
+
+use Elastica\Param;
+
+/**
+ * Class AbstractSuggestion.
+ */
+abstract class AbstractSuggest extends Param
+{
+ /**
+ * @var string the name of this suggestion
+ */
+ protected $_name;
+
+ /**
+ * @var string the text for this suggestion
+ */
+ protected $_text;
+
+ /**
+ * @param string $name
+ * @param string $field
+ */
+ public function __construct($name, $field)
+ {
+ $this->_name = $name;
+ $this->setField($field);
+ }
+
+ /**
+ * Suggest text must be set either globally or per suggestion.
+ *
+ * @param string $text
+ *
+ * @return $this
+ */
+ public function setText($text)
+ {
+ $this->_text = $text;
+
+ return $this;
+ }
+
+ /**
+ * @param string $field
+ *
+ * @return $this
+ */
+ public function setField($field)
+ {
+ return $this->setParam('field', $field);
+ }
+
+ /**
+ * @param int $size
+ *
+ * @return $this
+ */
+ public function setSize($size)
+ {
+ return $this->setParam('size', $size);
+ }
+
+ /**
+ * @param int $size maximum number of suggestions to be retrieved from each shard
+ *
+ * @return $this
+ */
+ public function setShardSize($size)
+ {
+ return $this->setParam('shard_size', $size);
+ }
+
+ /**
+ * Retrieve the name of this suggestion.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->_name;
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ $array = parent::toArray();
+ if (isset($this->_text)) {
+ $array['text'] = $this->_text;
+ }
+
+ return $array;
+ }
+}