<?php

namespace App\Entities\Equipment;

use App\Models\Equipment\ServerPartModel;

class ServerPartEntity extends EquipmentEntity
{
    const PK    = ServerPartModel::PK;
    const TITLE = ServerPartModel::TITLE;
    protected $attributes = [
        'title' => '',
        'type' => '',
        'billing' => '',
        'billing_at' => '',
        'cnt' => 0,
        'amount' => 0,
        'extra' => '',
    ];
    public function __construct(array|null $data = null)
    {
        parent::__construct($data);
    }
    public function  getClientInfoUid(): int|null
    {
        return $this->attributes['clientinfo_uid'] ?? null;
    }
    public function  getServiceInfoUid(): int|null
    {
        return $this->attributes['serviceinfo_uid'] ?? null;
    }
    public function  getServerInfoUid(): int|null
    {
        return $this->attributes['serverinfo_uid'] ?? null;
    }
    public function  getPartUid(): int|null
    {
        return $this->attributes['part_uid'] ?? null;
    }
    //기본기능용
    public function getCustomTitle(): string
    {
        return sprintf("%s*%d개[%s]", $this->getTitle(), $this->getCnt(), $this->getExtra());
    }
    public function getCalculatedAmount(): int
    {
        return $this->getAmount() * $this->getCnt();
    }
    public function getType(): string
    {
        return $this->attributes['type'] ?? "";
    }
    public function getBilling(): string
    {
        return $this->attributes['billing'] ?? "";
    }
    public function getBillingAt(): string
    {
        return $this->attributes['billing_at'] ?? "";
    }
    public function getCnt(): int
    {
        return $this->attributes['cnt'] ?? 0;
    }
    public function getAmount(): int
    {
        return $this->attributes['amount'] ?? 0;
    }
    public function getExtra(): string
    {
        return $this->attributes['extra'] ?? '';
    }
}
