src/Entity/Plan.php line 10

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PlanRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassPlanRepository::class)]
  7. class Plan
  8. {
  9.     /**
  10.      * Types de plan disponibles
  11.      */
  12.     public const TYPE_PLAN 'plan';
  13.     public const TYPE_EXTRA 'extra';
  14.     
  15.     /**
  16.      * Liste des types disponibles pour la validation et l'affichage dans les formulaires
  17.      */
  18.     public const TYPES = [
  19.         'Abonnement standard' => self::TYPE_PLAN,
  20.         'Option supplĂ©mentaire' => self::TYPE_EXTRA
  21.     ];
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue]
  24.     #[ORM\Column]
  25.     private ?int $id null;
  26.     #[ORM\Column(typeTypes::DECIMALprecision10scale'0')]
  27.     private ?string $price null;
  28.     #[ORM\Column(length255)]
  29.     private ?string $name null;
  30.     
  31.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  32.     private ?string $description null;
  33.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  34.     private ?string $longDescription null;
  35.     #[ORM\Column(nullabletrue)]
  36.     private ?int $socialMediaPlafond null;
  37.     
  38.     #[ORM\Column(length20)]
  39.     private ?string $type self::TYPE_PLAN;
  40.     
  41.     #[ORM\Column(type'boolean'options: ['default' => false])]
  42.     private bool $defaut false;
  43.     #[ORM\Column(typeTypes::DECIMALprecision5scale2options: ['default' => '20.00'])]
  44.     private ?string $remiseAnnuelle '20.00';
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getPrice(): ?string
  50.     {
  51.         return $this->price;
  52.     }
  53.     public function setPrice(string $price): static
  54.     {
  55.         $this->price $price;
  56.         return $this;
  57.     }
  58.     public function getSocialMediaPlafond(): ?int
  59.     {
  60.         return $this->socialMediaPlafond;
  61.     }
  62.     public function setSocialMediaPlafond(int $socialMediaPlafond): static
  63.     {
  64.         $this->socialMediaPlafond $socialMediaPlafond;
  65.         return $this;
  66.     }
  67.     public function getName(): ?string
  68.     {
  69.         return $this->name;
  70.     }
  71.     public function setName(string $name): static
  72.     {
  73.         $this->name $name;
  74.         return $this;
  75.     }
  76.     
  77.     public function getDescription(): ?string
  78.     {
  79.         return $this->description;
  80.     }
  81.     public function setDescription(?string $description): static
  82.     {
  83.         $this->description $description;
  84.         return $this;
  85.     }
  86.     public function getLongDescription(): ?string
  87.     {
  88.         return $this->longDescription;
  89.     }
  90.     public function setLongDescription(?string $longDescription): static
  91.     {
  92.         $this->longDescription $longDescription;
  93.         return $this;
  94.     }
  95.     public function __toString(): string
  96.     {
  97.         return $this->name ?? sprintf('Plan %d'$this->socialMediaPlafond);
  98.     }
  99.     
  100.     public function getType(): ?string
  101.     {
  102.         return $this->type;
  103.     }
  104.     public function setType(string $type): static
  105.     {
  106.         if (!in_array($type, [self::TYPE_PLANself::TYPE_EXTRA])) {
  107.             throw new \InvalidArgumentException(sprintf(
  108.                 'Type invalide "%s". Les types autorisĂ©s sont : %s',
  109.                 $type,
  110.                 implode(', ', [self::TYPE_PLANself::TYPE_EXTRA])
  111.             ));
  112.         }
  113.         
  114.         $this->type $type;
  115.         return $this;
  116.     }
  117.     
  118.     /**
  119.      * @return bool True si le plan est de type standard
  120.      */
  121.     public function isPlan(): bool
  122.     {
  123.         return $this->type === self::TYPE_PLAN;
  124.     }
  125.     
  126.     /**
  127.      * @return bool True si le plan est de type extra/option
  128.      */
  129.     public function isExtra(): bool
  130.     {
  131.         return $this->type === self::TYPE_EXTRA;
  132.     }
  133.     
  134.     public function isDefaut(): bool
  135.     {
  136.         return $this->defaut;
  137.     }
  138.     
  139.     public function setDefaut(bool $defaut): static
  140.     {
  141.         $this->defaut $defaut;
  142.         return $this;
  143.     }
  144.     public function getRemiseAnnuelle(): ?string
  145.     {
  146.         return $this->remiseAnnuelle;
  147.     }
  148.     public function setRemiseAnnuelle(?string $remiseAnnuelle): static
  149.     {
  150.         $this->remiseAnnuelle $remiseAnnuelle;
  151.         return $this;
  152.     }
  153. }