summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php62
1 files changed, 47 insertions, 15 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php
index 33c47cfd..612dc434 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php
@@ -1,14 +1,12 @@
<?php
-
namespace Elastica\Filter;
/**
- * Regexp filter
+ * Regexp filter.
*
- * @category Xodoa
- * @package Elastica
* @author Timothy Lamb <trash80@gmail.com>
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-regexp-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-filter.html
*/
class Regexp extends AbstractFilter
{
@@ -27,23 +25,34 @@ class Regexp extends AbstractFilter
protected $_regexp = '';
/**
- * Create Regexp object
+ * Holds the regexp options.
+ *
+ * @var array
+ */
+ protected $_options = array();
+
+ /**
+ * Create Regexp object.
+ *
+ * @param string $field Field name
+ * @param string $regexp Regular expression
+ * @param array $options Regular expression options
*
- * @param string $field Field name
- * @param string $regexp Regular expression
* @throws \Elastica\Exception\InvalidException
*/
- public function __construct($field = '', $regexp = '')
+ public function __construct($field = '', $regexp = '', $options = array())
{
$this->setField($field);
$this->setRegexp($regexp);
+ $this->setOptions($options);
}
/**
* Sets the name of the regexp field.
*
- * @param string $field Field name
- * @return \Elastica\Filter\Regexp
+ * @param string $field Field name
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -55,8 +64,9 @@ class Regexp extends AbstractFilter
/**
* Sets the regular expression query string.
*
- * @param string $regexp Regular expression
- * @return \Elastica\Filter\Regexp
+ * @param string $regexp Regular expression
+ *
+ * @return $this
*/
public function setRegexp($regexp)
{
@@ -66,14 +76,36 @@ class Regexp extends AbstractFilter
}
/**
- * Converts object to an array
+ * Sets the regular expression query options.
+ *
+ * @param array $options Regular expression options
+ *
+ * @return $this
+ */
+ public function setOptions($options)
+ {
+ $this->_options = $options;
+
+ return $this;
+ }
+
+ /**
+ * Converts object to an array.
*
* @see \Elastica\Filter\AbstractFilter::toArray()
+ *
* @return array data array
*/
public function toArray()
{
- $this->setParam($this->_field, $this->_regexp);
+ if (count($this->_options) > 0) {
+ $options = array('value' => $this->_regexp);
+ $options = array_merge($options, $this->_options);
+
+ $this->setParam($this->_field, $options);
+ } else {
+ $this->setParam($this->_field, $this->_regexp);
+ }
return parent::toArray();
}