<?php

namespace App\Entities\Equipment;

use App\Models\Equipment\ServerModel;

class ServerEntity extends EquipmentEntity
{
    const PK = ServerModel::PK;
    const TITLE = ServerModel::TITLE;

    public function __construct(array|null $data = null)
    {
        parent::__construct($data);
        $this->nullableFields = [
            ...$this->nullableFields,
            'clientinfo_uid',
            'serviceinfo_uid',
            'switchinfo_uid',
            'ip',
            'viewer',
            'os',
            'format_at',
        ];
    }
    final public function getClientInfoUid(): ?int
    {
        return $this->clientinfo_uid;
    }
    final public function getServiceInfoUid(): ?int
    {
        return $this->serviceinfo_uid;
    }
    final public function getChassisInfoUid(): int
    {
        return $this->chassisinfo_uid;
    }
    final public function getSwitchInfoUid(): ?int
    {
        return $this->switchinfo_uid;
    }

    //기본기능용
    public function getCustomTitle(mixed $title = null): string
    {
        return sprintf("[%s]%s", $this->getCode(), $title ? $title : $this->getIP());
    }
    final public function getCode(): string
    {
        return $this->code;
    }
    public function getType(): ?string
    {
        return $this->type;
    }
    public function getIP(): ?string
    {
        return $this->ip;
    }

    public function getViewer(): ?string
    {
        return $this->viewer;
    }

    public function getOS(): ?string
    {
        return $this->os;
    }
    public function getPrice(): int
    {
        return (int) ($this->price ?? 0);
    }
    public function getManufacturAt(): string
    {
        return $this->manufactur_at;
    }
    public function getFormatAt(): ?string
    {
        $this->format_at;
    }
}
