Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

src/Service/BrandService.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use App\Entity\Brand;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  6. class BrandService
  7. {
  8.     private ?Brand $brand;
  9.     public const CODE_ADN 'adn';
  10.     public const CODE_NPCJ 'npcj';
  11.     public const CODE_PMDV 'pmdv';
  12.     /**
  13.      * @param ParameterBagInterface $parameterBag
  14.      * @param EntityManagerInterface $em
  15.      */
  16.     public function __construct(ParameterBagInterface $parameterBag, private EntityManagerInterface $em)
  17.     {
  18.         $this->brand $em->getRepository(Brand::class)->findOneByCode($parameterBag->get('brand'));
  19.     }
  20.     /**
  21.      * @return Brand|null
  22.      */
  23.     public function getBrand(): ?Brand
  24.     {
  25.         return $this->brand;
  26.     }
  27.     public function findBrand(string $code): ?Brand
  28.     {
  29.         return $this->em->getRepository(Brand::class)->findOneByCode($code);
  30.     }
  31.     /**
  32.      * @return bool
  33.      */
  34.     public function isADN(): bool
  35.     {
  36.         return $this->brand->getCode() == self::CODE_ADN;
  37.     }
  38.     /**
  39.      * @return bool
  40.      */
  41.     public function isPMDV(): bool
  42.     {
  43.         return $this->brand->getCode() == self::CODE_PMDV;
  44.     }
  45.     /**
  46.      * @return bool
  47.      */
  48.     public function isNPCJ(): bool
  49.     {
  50.         return $this->brand->getCode() == self::CODE_NPCJ;
  51.     }
  52. }