|  | @@ -0,0 +1,82 @@
 | 
	
		
			
				|  |  | +<?php
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +namespace App\Yr\Forecast\Tabular;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +use App\Yr\Forecast\Tabular\Time\Pressure;
 | 
	
		
			
				|  |  | +use App\Yr\Forecast\Tabular\Time\Symbol;
 | 
	
		
			
				|  |  | +use App\Yr\Forecast\Tabular\Time\Temperature;
 | 
	
		
			
				|  |  | +use App\Yr\Forecast\Tabular\Time\WindDirection;
 | 
	
		
			
				|  |  | +use App\Yr\Forecast\Tabular\Time\WindSpeed;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +final class Time implements \IteratorAggregate {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private $from;
 | 
	
		
			
				|  |  | +    private $until;
 | 
	
		
			
				|  |  | +    private $period;
 | 
	
		
			
				|  |  | +    private $symbol;
 | 
	
		
			
				|  |  | +    private $windDirection;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function __construct(\SimpleXMLElement $xml) {
 | 
	
		
			
				|  |  | +        $this->from = new \DateTimeImmutable($xml['from']);
 | 
	
		
			
				|  |  | +        $this->until = new \DateTimeImmutable($xml['to']);
 | 
	
		
			
				|  |  | +        $this->period = (int)$xml['period'];
 | 
	
		
			
				|  |  | +        $this->symbol = new Symbol($xml->symbol);
 | 
	
		
			
				|  |  | +        $this->windDirection = new WindDirection($xml->windDirection);
 | 
	
		
			
				|  |  | +        $this->windSpeed= new WindSpeed($xml->windSpeed);
 | 
	
		
			
				|  |  | +        $this->temperature = new Temperature($xml->temperature);
 | 
	
		
			
				|  |  | +        $this->pressure = new Pressure($xml->pressure);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function getPeriod(): int {
 | 
	
		
			
				|  |  | +        return $this->period;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function getFrom(): \DateTimeImmutable {
 | 
	
		
			
				|  |  | +        return $this->from;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function getUntil(): \DateTimeImmutable {
 | 
	
		
			
				|  |  | +        return $this->until;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function getSymbol(): Symbol {
 | 
	
		
			
				|  |  | +        return $this->symbol;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function getWindDirection(): WindDirection {
 | 
	
		
			
				|  |  | +        return $this->getWindDirection();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function getWindSpeed(): WindSpeed {
 | 
	
		
			
				|  |  | +        return $this->windSpeed;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function getTemperature(): Temperature {
 | 
	
		
			
				|  |  | +        return $this->temperature;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function getPressure(): Pressure {
 | 
	
		
			
				|  |  | +        return $this->pressure;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function getIterator(): \Generator {
 | 
	
		
			
				|  |  | +        foreach ([
 | 
	
		
			
				|  |  | +            $this->getSymbol(),
 | 
	
		
			
				|  |  | +            $this->getWindDirection(),
 | 
	
		
			
				|  |  | +            $this->getWindSpeed(),
 | 
	
		
			
				|  |  | +            $this->getTemperature(),
 | 
	
		
			
				|  |  | +            $this->getPressure(),
 | 
	
		
			
				|  |  | +        ] as $entity)
 | 
	
		
			
				|  |  | +            yield $entity;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function __toString(): string {
 | 
	
		
			
				|  |  | +        return sprintf(
 | 
	
		
			
				|  |  | +            '%s - %s: %s, %s, %s, %s, %s',
 | 
	
		
			
				|  |  | +            $this->from->format('H:i'), $this->until->format('H:i'),
 | 
	
		
			
				|  |  | +            $this->symbol, $this->windDirection, $this->windSpeed,
 | 
	
		
			
				|  |  | +            $this->temperature, $this->pressure
 | 
	
		
			
				|  |  | +        );
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +}
 |