diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-08-16 08:22:05 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-08-16 08:22:05 +0200 |
commit | 1a365e77dfb8825136626202b1df462731b42060 (patch) | |
tree | 1dc4468eaabf070e051e790a9e67a9a9a2c63d99 /vendor/ruflin/elastica/lib/Elastica/Index/Stats.php | |
parent | a72fd280f7acb4d2a1ba579a0f1b2b2ae8958530 (diff) |
Update to MediaWiki 1.25.2
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Index/Stats.php')
-rw-r--r-- | vendor/ruflin/elastica/lib/Elastica/Index/Stats.php | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php b/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php new file mode 100644 index 00000000..9312e273 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php @@ -0,0 +1,109 @@ +<?php + +namespace Elastica\Index; +use Elastica\Index as BaseIndex; +use Elastica\Request; + +/** + * Elastica index stats object + * + * @category Xodoa + * @package Elastica + * @author Nicolas Ruflin <spam@ruflin.com> + * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-stats.html + */ +class Stats +{ + /** + * Response + * + * @var \Elastica\Response Response object + */ + protected $_response = null; + + /** + * Stats info + * + * @var array Stats info + */ + protected $_data = array(); + + /** + * Index + * + * @var \Elastica\Index Index object + */ + protected $_index = null; + + /** + * Construct + * + * @param \Elastica\Index $index Index object + */ + public function __construct(BaseIndex $index) + { + $this->_index = $index; + $this->refresh(); + } + + /** + * Returns the raw stats info + * + * @return array Stats info + */ + public function getData() + { + return $this->_data; + } + + /** + * Returns the entry in the data array based on the params. + * Various params possible. + * + * @return mixed Data array entry or null if not found + */ + public function get() + { + $data = $this->getData(); + + foreach (func_get_args() as $arg) { + if (isset($data[$arg])) { + $data = $data[$arg]; + } else { + return null; + } + } + + return $data; + } + + /** + * Returns the index object + * + * @return \Elastica\Index Index object + */ + public function getIndex() + { + return $this->_index; + } + + /** + * Returns response object + * + * @return \Elastica\Response Response object + */ + public function getResponse() + { + return $this->_response; + } + + /** + * Reloads all status data of this object + */ + public function refresh() + { + $path = '_stats'; + $this->_response = $this->getIndex()->request($path, Request::GET); + $this->_data = $this->getResponse()->getData(); + } +} |