2014-07-17 02:12:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhrequentTimeSlices extends Phobject {
|
|
|
|
|
|
|
|
private $objectPHID;
|
|
|
|
private $isOngoing;
|
|
|
|
private $ranges;
|
|
|
|
|
|
|
|
public function __construct($object_phid, $is_ongoing, array $ranges) {
|
|
|
|
$this->objectPHID = $object_phid;
|
|
|
|
$this->isOngoing = $is_ongoing;
|
|
|
|
$this->ranges = $ranges;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getObjectPHID() {
|
|
|
|
return $this->objectPHID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDuration($now) {
|
2014-08-08 02:05:14 +02:00
|
|
|
$total = 0;
|
2014-07-17 02:12:38 +02:00
|
|
|
foreach ($this->ranges as $range) {
|
|
|
|
if ($range[1] === null) {
|
2014-08-08 02:05:14 +02:00
|
|
|
$total += $now - $range[0];
|
2014-07-17 02:12:38 +02:00
|
|
|
} else {
|
2014-08-08 02:05:14 +02:00
|
|
|
$total += $range[1] - $range[0];
|
2014-07-17 02:12:38 +02:00
|
|
|
}
|
|
|
|
}
|
2014-08-08 02:05:14 +02:00
|
|
|
return $total;
|
2014-07-17 02:12:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getIsOngoing() {
|
|
|
|
return $this->isOngoing;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRanges() {
|
|
|
|
return $this->ranges;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|