src/Model/Domain.php line 44

Open in your IDE?
  1. <?php
  2. namespace App\Model;
  3. use Symfony\Component\Validator\Constraints as Assert;
  4. use App\Util\Api;
  5. class Domain implements \JsonSerializable
  6. {
  7.     /**
  8.      * @Assert\NotBlank()
  9.      */
  10.     private $domain;
  11.     // options
  12.     private $options;
  13.     
  14.     public const DOMAIN_REGEX '/^[a-z0-9_\-.,+]+$/';
  15.     public const MANY_DOMAINS_REGEX '/^[a-z0-9_\- .,+]+$/';
  16.     
  17.     public function getDomain(): ?string
  18.     {
  19.         return $this->domain;
  20.     }
  21.     
  22.     public function setDomain(string $domain): self
  23.     {
  24.         $this->domain $domain;
  25.         
  26.         return $this;
  27.     }
  28.     
  29.     public function getOptions(): ?array
  30.     {
  31.         return $this->options;
  32.     }
  33.     
  34.     public function setOptions(array $options): self
  35.     {
  36.         $this->options $options;
  37.         
  38.         return $this;
  39.     }    
  40.     
  41.     public function jsonSerialize()
  42.     {
  43.         $vars get_object_vars($this);
  44.         return $vars;
  45.     }    
  46.     
  47.     /**
  48.      * returns value of the option or return null if not found
  49.      * @param string $name or null
  50.      */
  51.     public function findOption(string $name)
  52.     {
  53.         if(array_key_exists($name$this->options)) {
  54.             return $this->options[$name];
  55.         }
  56.         else {
  57.             return null;
  58.         }
  59.     }
  60.     
  61.     public function deleteOption(string $name)
  62.     {
  63.         if(array_key_exists($name$this->options)) {
  64.             unset($this->options[$name]);
  65.         }
  66.     }
  67.     
  68.     public function setOption(string $namestring $val)
  69.     {
  70.         $this->options[$name] = $val;
  71.         return $this;
  72.     }        
  73. }