File: D:/HostingSpaces/SBogers10/farmfun.komma.pro/app/Komma/Locations/Types/DayInfo.php
<?php
namespace App\Komma\Locations\Types;
use Carbon\Carbon;
/**
* @property bool $open
* @property Carbon $from
* @property Carbon $till
* @property Carbon $latest_start
*
* Class DayInfo
*/
final class DayInfo
{
/**
* Variables that will be used in the construct to make the specific DateTime
*
* @var array
*/
private $timeConstructors = [
'from', 'till', 'latest_start',
];
/** @var bool */
public $open;
/** @var Carbon */
public $from;
/** @var Carbon */
public $till;
/** @var Carbon */
public $latest_start;
/**
* Make the day info
*
* DayInfo constructor.
* @param Carbon $date
* @param bool $open
* @param string $from
* @param string $till
* @param string $latest_start
*/
public function __construct(Carbon $date, bool $open, string $from, string $till, string $latest_start)
{
$this->open = $open;
// Create Carbon DateTime from a combination fo the given $date and time constructor (ex. $open)
foreach ($this->timeConstructors as $timeConstructor) {
$this->{$timeConstructor} = Carbon::createFromFormat(Carbon::DEFAULT_TO_STRING_FORMAT, $date->format('Y-m-d').' '.${$timeConstructor});
}
}
}