<?php


namespace common\util;


use common\models\AccidentCases;
use JsonSerializable;

/**
 * Class AccidentCasesFocusObj
 * @package common\util
 * @property int $id
 * @property string $title
 * @property string images
 * @property int start_time
 */
class AccidentCasesFocusObj implements JsonSerializable
{
    private int $id;

    private ?string $title;

    private ?string $images;

    private ?int $start_time;

    /**
     * @return int
     */
    public function getId(): int
    {
        return $this->id;
    }

    /**
     * @param int $id
     */
    public function setId(int $id): void
    {
        $this->id = $id;
    }

    /**
     * @return string
     */
    public function getTitle(): string
    {
        return $this->title;
    }

    /**
     * @param string $title
     */
    public function setTitle(string $title): void
    {
        $this->title = $title;
    }


    public function __construct(AccidentCases $AccidentCases)
    {
        $this->id = $AccidentCases->id;
        $this->title = $AccidentCases->title;
        $this->images = $AccidentCases->images;
        $this->start_time = $AccidentCases->start_time;
    }

    /**
     * json_encode无法转化私有属性，需要使用jsonSerialize自定义转换私有的属性
     * @return array
     */
    public function jsonSerialize(): array
    {
        return [
            "id" => $this->id,
            "title" => $this->title,
            "images" => $this->images,
            "start_time" => $this->start_time,
        ];
    }
}