src/Entity/CalendarEventKind.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CalendarEventKindRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=CalendarEventKindRepository::class)
  7.  */
  8. class CalendarEventKind
  9. {
  10.     /**
  11.      * @ORM\Id
  12.      * @ORM\GeneratedValue
  13.      * @ORM\Column(type="integer")
  14.      */
  15.     private $id;
  16.     /**
  17.      * @ORM\Column(type="string", length=255)
  18.      */
  19.     private $name;
  20.     /**
  21.      * @ORM\Column(type="datetime")
  22.      */
  23.     private $createdAt;
  24.     /**
  25.      * @ORM\Column(type="string", length=255, nullable=true)
  26.      */
  27.     private $nameRegex;
  28.     /**
  29.      * @ORM\Column(type="string", length=20, unique=true)
  30.      */
  31.     private $kindId;
  32.     public function __construct()
  33.     {
  34.         $this->createdAt = new \DateTime();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getName(): ?string
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function setName(string $name): self
  45.     {
  46.         $this->name $name;
  47.         return $this;
  48.     }
  49.     public function getCreatedAt(): ?\DateTimeInterface
  50.     {
  51.         return $this->createdAt;
  52.     }
  53.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  54.     {
  55.         $this->createdAt $createdAt;
  56.         return $this;
  57.     }
  58.     public function getNameRegex(): ?string
  59.     {
  60.         return $this->nameRegex;
  61.     }
  62.     public function getNameRegexWords(): array
  63.     {
  64.         if (!$this->getNameRegex()) {
  65.             return [];
  66.         }
  67.         $wordsStr $this->getNameRegex();
  68.         return preg_split("/, */"$wordsStr, -1PREG_SPLIT_NO_EMPTY);
  69.     }
  70.     public function getNameFullRegex(): ?string
  71.     {
  72.         static $nonLetterRegex "[^а-яА-ЯёЁ\s\-]";
  73.         if (!$this->getNameRegex()) {
  74.             return null;
  75.         }
  76.         $words $this->getNameRegexWords();
  77. //        $words = array_map(function ($word) use ($nonLetterRegex) {
  78. //            $word = preg_quote($word, "/");
  79. //            $word .= "($nonLetterRegex|$)";
  80. //            return $word;
  81. //        }, $words);
  82.         return "/" implode("|"$words) . "/u";
  83.     }
  84.     public function setNameRegex(?string $nameRegex): self
  85.     {
  86.         $this->nameRegex $nameRegex;
  87.         return $this;
  88.     }
  89.     public function getKindId(): ?string
  90.     {
  91.         return $this->kindId;
  92.     }
  93.     public function setKindId(string $kindId): self
  94.     {
  95.         $this->kindId $kindId;
  96.         return $this;
  97.     }
  98. }