25 lines
619 B
PHP
25 lines
619 B
PHP
<?php
|
|
|
|
namespace App\Features\History\Services;
|
|
|
|
use App\Contracts\PriceRepository;
|
|
use App\Data\ElectricityData;
|
|
use App\Data\GasData;
|
|
use App\Features\History\Data\HistoryData;
|
|
use Carbon\Carbon;
|
|
|
|
class HistoryService
|
|
{
|
|
public function __construct(
|
|
public PriceRepository $repository
|
|
) {}
|
|
|
|
public function getHistoryData(Carbon $date): HistoryData
|
|
{
|
|
$electricity = ElectricityData::collect($this->repository->retrieveElectricityForDate($date));
|
|
$gas = GasData::collect($this->repository->retrieveGasForDate($date));
|
|
|
|
return new HistoryData($electricity, $gas);
|
|
}
|
|
}
|