<?php

namespace App\Entity;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\DegradationRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;

#[ORM\Entity(repositoryClass: DegradationRepository::class)]
#[ORM\Table(name: 'degrado')]
#[ApiResource(
    operations: [
        new Get(normalizationContext: ['groups' => 'degradation:item']),
        new GetCollection(normalizationContext: ['groups' => 'degradation:list'])
    ],
    order: ['term' => 'DESC'],
    paginationEnabled: false,
)]
class Degradation
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    #[Groups(['degradation:list', 'degradation:item'])]
    private ?int $id = null;

    #[ORM\Column(length: 50, name: 'lemma')]
    #[Groups(['degradation:list', 'degradation:item'])]
    private ?string $term = null;

    #[ORM\Column(length: 50, nullable: true, name: 'classe')]
    #[Groups(['degradation:list', 'degradation:item'])]
    private ?string $class = null;

    #[ORM\Column(type: Types::BIGINT, nullable: true, name: 'materiale')]
    //#[ORM\ManyToOne()]
    #[Groups(['degradation:list', 'degradation:item'])]
    private ?string $material = null;

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

    public function setId(string $id): static
    {
        $this->id = $id;

        return $this;
    }

    public function getTerm(): ?string
    {
        return $this->term;
    }

    public function setTerm(string $term): static
    {
        $this->term = $term;

        return $this;
    }

    public function getClass(): ?string
    {
        return $this->class;
    }

    public function setClass(?string $class): static
    {
        $this->class = $class;

        return $this;
    }

    public function getMaterial(): ?string
    {
        return $this->material;
    }

    public function setMaterial(?string $material): static
    {
        $this->material = $material;

        return $this;
    }
}
