|
@@ -4,6 +4,7 @@ namespace App\Yr\Forecast\Tabular\Variation;
|
|
|
|
|
|
use App\Yr\Forecast\Tabular\Time;
|
|
|
use App\Yr\Forecast\Tabular\Time\DiffInterface;
|
|
|
+use App\Yr\Forecast\Tabular\TimeInterface;
|
|
|
|
|
|
if (!function_exists('array_key_last')) {
|
|
|
function array_key_last(array $args): ?int {
|
|
@@ -28,7 +29,7 @@ class VariationFn {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class Variation implements \IteratorAggregate {
|
|
|
+class Variation implements TimeInterface, \IteratorAggregate {
|
|
|
|
|
|
private $time;
|
|
|
private $entities = [];
|
|
@@ -54,6 +55,14 @@ class Variation implements \IteratorAggregate {
|
|
|
return $this->time;
|
|
|
}
|
|
|
|
|
|
+ public function getFrom(): \DateTimeImmutable {
|
|
|
+ return $this->time->getFrom();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getUntil(): \DateTimeImmutable {
|
|
|
+ return $this->time->getUntil();
|
|
|
+ }
|
|
|
+
|
|
|
private function getEntityKey(DiffInterface $entity): ?int {
|
|
|
$key = (function() use ($entity) : ?int {
|
|
|
foreach ($this->entities as $key => $ent)
|
|
@@ -115,7 +124,7 @@ class Variation implements \IteratorAggregate {
|
|
|
$var = new Variation($this->time);
|
|
|
|
|
|
foreach ($entities as $entity)
|
|
|
- $var->addEntity($entity, $this->getIntersect($entity));
|
|
|
+ $var->addEntity($entity, null);
|
|
|
|
|
|
return $var;
|
|
|
}
|
|
@@ -137,7 +146,7 @@ class Variation implements \IteratorAggregate {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public function getIterator(): ?\Generator {
|
|
|
+ public function getIterator(): \Generator {
|
|
|
foreach ($this->entities as $entity)
|
|
|
yield $entity;
|
|
|
|