Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. <?php
  2. declare(strict_types=1);
  3.  
  4. namespace App\Entity;
  5.  
  6. use Doctrine\ORM\Mapping as ORM;
  7.  
  8. /**
  9.  * @ORM\Entity
  10.  */
  11. class FooBar
  12. {
  13.     /** @ORM\Id @ORM\Column(type="integer", nullable=false) @ORM\GeneratedValue **/
  14.     private ?int $id;
  15.  
  16.     /** @ORM\Column(type="string", nullable=false) */
  17.     private string $foobar;
  18.  
  19.     public function __construct(string $foobar)
  20.     {
  21.         $this->foobar = $foobar;
  22.     }
  23.  
  24.     public function getFoobar()
  25.     {
  26.         if ($this->foobar === null){
  27.             throw new \LogicException('Foobar should not be retrieved before being hydrated.');
  28.         }
  29.         return $this->foobar;
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement