<?php


namespace common\util;


use common\models\Rules;
use JsonSerializable;

/**
 * Class RulesWithContentObj
 * @package common\util
 * @property int $id
 * @property string $rule_name
 * @property array $rule_content
 * @property array $content
 * @property string $rule_category
 * @property int $rule_status
 * @property string $create_time
 * @property string $update_time
 * @property string $version
 */
class RulesWithContentObj implements JsonSerializable
{
    private $id;

    private $rule_name;

    private $rule_category;

    private $rule_content;

    private $content;

    private $rule_status;

    private $create_time;
    private $end_time;

    private $update_time;

    private $version;

    /**
     * @return string|null
     */
    public function getContent(): ?string
    {
        return $this->content;
    }

    /**
     * @param string|null $content
     */
    public function setContent(?string $content): void
    {
        $this->content = $content;
    }

    /**
     * @return string
     */
    public function getRuleContent(): array
    {
        return $this->rule_content;
    }

    /**
     * @param array $point_content
     */
    public function setRuleContent(array $point_content)
    {
        $this->rule_content = $point_content;
    }

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

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

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

    /**
     * @param string $rule_name
     */
    public function setRuleName(string $rule_name)
    {
        $this->rule_name = $rule_name;
    }

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

    /**
     * @param string $rule_category
     */
    public function setRuleCategory(string $rule_category)
    {
        $this->rule_category = $rule_category;
    }

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

    /**
     * @param int $rule_status
     */
    public function setRuleStatus(int $rule_status)
    {
        $this->rule_status = $rule_status;
    }

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

    /**
     * @param string $create_time
     */
    public function setCreateTime(string $create_time)
    {
        $this->create_time = $create_time;
    }

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

    /**
     * @param string $update_time
     */
    public function setUpdateTime(string $update_time)
    {
        $this->update_time = $update_time;
    }

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

    /**
     * @param string $version
     */
    public function setVersion(string $version)
    {
        $this->version = $version;
    }

    public function __construct(Rules $rules)
    {
        $this->id = $rules->id;
        $this->rule_name = $rules->rule_name;
        $this->content = $rules->rule_content;
        $this->rule_category = $rules->rule_category;
        $this->rule_status = $rules->rule_status;
        $this->create_time = $rules->create_time;
        $this->end_time = $rules->end_time;
        $this->update_time = $rules->update_time;
        $this->version = $rules->version;
    }

    /**
     * json_encode无法转化私有属性，需要使用jsonSerialize自定义转换私有的属性
     * @return array
     */
    public function jsonSerialize(): array
    {
        return [
            "id" => $this->id,
            "rule_name" => $this->rule_name,
            "rule_content" => $this->rule_content,
            "content" => $this->content,
            "rule_category" => $this->rule_category,
            "rule_status" => $this->rule_status,
            "create_time" => $this->create_time,
            "end_time" => $this->end_time,
            "update_time" => $this->update_time,
            "version" => $this->version,
        ];
    }
}