<?php

declare(strict_types=1);

namespace OCA\Mitgliederverwaltung\Db;

use JsonSerializable;
use OCP\AppFramework\Db\Entity;

/**
 * General material entity mapping all columns from oc_mv_inventory_general_material.
 *
 * Part of Issue #165 (Inventory Tracking).
 *
 * @method int|null getId()
 * @method void setId(int $id)
 * @method string getName()
 * @method void setName(string $name)
 * @method int|null getCondition()
 * @method void setCondition(?int $condition)
 * @method string|null getNotes()
 * @method void setNotes(?string $notes)
 * @method string getCreatedAt()
 * @method void setCreatedAt(string $createdAt)
 * @method string getUpdatedAt()
 * @method void setUpdatedAt(string $updatedAt)
 */
class GeneralMaterial extends Entity implements JsonSerializable {

    protected int $id = 0;
    protected string $name = '';
    protected ?int $condition = null;
    protected ?string $notes = null;
    protected string $createdAt = '';
    protected string $updatedAt = '';

    public function __construct() {
        $this->addType('id', 'integer');
        $this->addType('condition', 'integer');
    }

    public function jsonSerialize(): array {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'condition' => $this->condition,
            'notes' => $this->notes,
            'created_at' => $this->createdAt,
            'updated_at' => $this->updatedAt,
        ];
    }
}
