/**
  * Extracts a sorted range of TimePoint
  *
  * @param array $tags
  * @return array
  */
 protected function getRange($tags)
 {
     $range = $this->timeLine->find($tags, TimePoint::TARGET_SERVER);
     TimePoint::sort($range);
     return $range;
 }
 /**
  * Computes the duration between two TimePoint
  * @param TimePoint $start
  * @param TimePoint $end
  * @return float
  * @throws InconsistentRangeException
  */
 protected function getRangeDuration($start, $end)
 {
     // the two TimePoint must have the same target to be consistent
     if ($start->getTarget() != $end->getTarget()) {
         throw new InconsistentRangeException('A time range must be defined by two TimePoint with the same target');
     }
     // the two TimePoint must be correctly ordered
     $rangeDuration = $end->getTimestamp() - $start->getTimestamp();
     if ($rangeDuration < 0) {
         throw new InconsistentRangeException('A START TimePoint cannot take place after the END!');
     }
     return $rangeDuration;
 }
 /**
  * Test TimePoint::sort() method
  * @dataProvider testSortProvider
  */
 public function testSort(array $range, array $expectedResult)
 {
     $this->assertEquals($expectedResult, TimePoint::sort($range));
 }