Commit 3fc0b564 authored by Nathan Bell's avatar Nathan Bell

Fixes Issue #108: provide start, end and gap values in facet range results

parent 5c7afe1c
......@@ -174,6 +174,9 @@ class Solarium_Client_ResponseParser_Select_Component_FacetSet
$before = (isset($data['before'])) ? $data['before'] : null;
$after = (isset($data['after'])) ? $data['after'] : null;
$between = (isset($data['between'])) ? $data['between'] : null;
$start = (isset($data['start'])) ? $data['start'] : null;
$end = (isset($data['end'])) ? $data['end'] : null;
$gap = (isset($data['gap'])) ? $data['gap'] : null;
$offset = 0;
$counts = array();
......@@ -182,8 +185,8 @@ class Solarium_Client_ResponseParser_Select_Component_FacetSet
$offset += 2;
}
return new Solarium_Result_Select_Facet_Range($counts, $before, $after, $between);
return new Solarium_Result_Select_Facet_Range($counts, $before, $after, $between, $start, $end, $gap);
}
}
}
\ No newline at end of file
}
......@@ -73,6 +73,27 @@ class Solarium_Result_Select_Facet_Range extends Solarium_Result_Select_Facet_Fi
*/
protected $_between;
/**
* The lower bound of the ranges
*
* @var string
*/
protected $_start;
/**
* The upper bound of all ranges
*
* @var string
*/
protected $_end;
/**
* The gap between each range
*
* @var string
*/
protected $_gap;
/**
* Constructor
*
......@@ -82,12 +103,15 @@ class Solarium_Result_Select_Facet_Range extends Solarium_Result_Select_Facet_Fi
* @param int $between
* @return void
*/
public function __construct($values, $before, $after, $between)
public function __construct($values, $before, $after, $between, $start, $end, $gap)
{
$this->_values = $values;
$this->_before = $before;
$this->_after = $after;
$this->_between = $between;
$this->_start = $start;
$this->_end = $end;
$this->_gap = $gap;
}
/**
......@@ -129,4 +153,40 @@ class Solarium_Result_Select_Facet_Range extends Solarium_Result_Select_Facet_Fi
return $this->_between;
}
}
\ No newline at end of file
/**
* Get 'start' value of the ranges
*
* The start value specified in the query facet.
*
* @return string
*/
public function getStart()
{
return $this->_start;
}
/**
* Get 'end' value of the ranges
*
* The end value specified in the query facet
*
* @return string
*/
public function getEnd()
{
return $this->_end;
}
/**
* Get 'gap' between the start and end of each range
*
* Get the gap specified in the query facet
*
* @return string
*/
public function getGap()
{
return $this->_gap;
}
}
......@@ -37,7 +37,7 @@ class Solarium_Result_Select_Facet_RangeTest extends PHPUnit_Framework_TestCase
*/
protected $_facet;
protected $_values, $_before, $_after, $_between;
protected $_values, $_before, $_after, $_between, $_start, $_end, $_gap;
public function setUp()
{
......@@ -49,8 +49,11 @@ class Solarium_Result_Select_Facet_RangeTest extends PHPUnit_Framework_TestCase
$this->_before = 2;
$this->_after = 4;
$this->_between = 3;
$this->_start = '10.0';
$this->_end = '40.0';
$this->_gap = '10.0';
$this->_facet = new Solarium_Result_Select_Facet_Range($this->_values, $this->_before, $this->_after, $this->_between);
$this->_facet = new Solarium_Result_Select_Facet_Range($this->_values, $this->_before, $this->_after, $this->_between, $this->_start, $this->_end, $this->_gap);
}
public function testGetValues()
......@@ -89,4 +92,18 @@ class Solarium_Result_Select_Facet_RangeTest extends PHPUnit_Framework_TestCase
$this->assertEquals($this->_between, $this->_facet->getBetween());
}
public function testGetStart()
{
$this->assertEquals($this->_start, $this->_facet->getStart());
}
public function testGetEnd()
{
$this->assertEquals($this->_end, $this->_facet->getEnd());
}
public function testGetGap()
{
$this->assertEquals($this->_gap, $this->_facet->getGap());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment