HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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});
        }
    }
}