src/Entity/GodChild.php line 13

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\GodChildRepository;
  4.     use App\Traits\DateTrait;
  5.     use Doctrine\ORM\Mapping as ORM;
  6.     use ReflectionClass;
  7.     /**
  8.      * @ORM\Entity(repositoryClass=GodChildRepository::class)
  9.      */
  10.     class GodChild
  11.     {
  12.         const STATUS_PENDING  'pending';
  13.         const STATUS_VALID    'valid';
  14.         const STATUS_CANCELED 'canceled';
  15.         /**
  16.          * @ORM\Id
  17.          * @ORM\GeneratedValue
  18.          * @ORM\Column(type="integer")
  19.          */
  20.         private $id;
  21.         /**
  22.          * @ORM\Column(type="string", length=10)
  23.          */
  24.         private $civility;
  25.         /**
  26.          * @ORM\Column(type="string", length=255)
  27.          */
  28.         private $lastName;
  29.         /**
  30.          * @ORM\Column(type="string", length=255)
  31.          */
  32.         private $firstName;
  33.         /**
  34.          * @ORM\Column(type="string", length=255, nullable=true)
  35.          */
  36.         private $company;
  37.         /**
  38.          * @ORM\Column(type="string", length=255, nullable=true)
  39.          */
  40.         private $email;
  41.         /**
  42.          * @ORM\Column(type="string", length=255)
  43.          */
  44.         private $address1;
  45.         /**
  46.          * @ORM\Column(type="string", length=255, nullable=true)
  47.          */
  48.         private $address2;
  49.         /**
  50.          * @ORM\Column(type="string", length=30)
  51.          */
  52.         private $zipcode;
  53.         /**
  54.          * @ORM\Column(type="string", length=255)
  55.          */
  56.         private $city;
  57.         /**
  58.          * @ORM\Column(type="string", length=3)
  59.          */
  60.         private $country;
  61.         /**
  62.          * @ORM\Column(type="string", length=20)
  63.          */
  64.         private $phone;
  65.         /**
  66.          * @ORM\Column(type="integer", options={"default":0})
  67.          */
  68.         private $points 0;
  69.         /**
  70.          * @ORM\Column(type="string", length=64, options={"default":self::STATUS_PENDING})
  71.          */
  72.         private $status self::STATUS_PENDING;
  73.         /**
  74.          * @ORM\ManyToOne(targetEntity=User::class, inversedBy="godchilds")
  75.          * @ORM\JoinColumn(nullable=false)
  76.          */
  77.         private $user;
  78.         /**
  79.          * @ORM\Column(type="text", nullable=true)
  80.          */
  81.         private $reason;
  82.         /**
  83.          * @ORM\Column(type="text", nullable=true)
  84.          */
  85.         private $identifier;
  86.         use DateTrait;
  87.         /*
  88.          * ============================================================================================
  89.          * =============================== FONCTIONS CUSTOM ===========================================
  90.          * ============================================================================================
  91.          */
  92.         /**
  93.          * @return array
  94.          */
  95.         static function getStatuses(): array
  96.         {
  97.             $oClass       = new ReflectionClass__CLASS__ );
  98.             $constantType = [];
  99.             foreach ( $oClass->getConstants() as $c ) {
  100.                 $constantType$c ] = $c;
  101.             }
  102.             return $constantType;
  103.         }
  104.         /**
  105.          * @return string
  106.          */
  107.         public function getNameCiv(): string
  108.         {
  109.             return trimstrtoupper$this->civility ) . ' ' trim$this->firstName " " $this->lastName ) );
  110.         }
  111.         /**
  112.          * @return mixed
  113.          */
  114.         public function getUsernameFromName()
  115.         {
  116.             $username $this->getName();
  117.             $username str_replace( [ 'Á',
  118.                                        'À',
  119.                                        'Â',
  120.                                        'Ä',
  121.                                        'Ã',
  122.                                        'Å',
  123.                                        'Ç',
  124.                                        'É',
  125.                                        'È',
  126.                                        'Ê',
  127.                                        'Ë',
  128.                                        'Í',
  129.                                        'Ï',
  130.                                        'Î',
  131.                                        'Ì',
  132.                                        'Ñ',
  133.                                        'Ó',
  134.                                        'Ò',
  135.                                        'Ô',
  136.                                        'Ö',
  137.                                        'Õ',
  138.                                        'Ú',
  139.                                        'Ù',
  140.                                        'Û',
  141.                                        'Ü',
  142.                                        'Ý' ], [ 'A',
  143.                                                 'A',
  144.                                                 'A',
  145.                                                 'A',
  146.                                                 'A',
  147.                                                 'A',
  148.                                                 'C',
  149.                                                 'E',
  150.                                                 'E',
  151.                                                 'E',
  152.                                                 'E',
  153.                                                 'I',
  154.                                                 'I',
  155.                                                 'I',
  156.                                                 'I',
  157.                                                 'N',
  158.                                                 'O',
  159.                                                 'O',
  160.                                                 'O',
  161.                                                 'O',
  162.                                                 'O',
  163.                                                 'U',
  164.                                                 'U',
  165.                                                 'U',
  166.                                                 'U',
  167.                                                 'Y' ], $username );
  168.             $username str_replace( [ 'á',
  169.                                        'à',
  170.                                        'â',
  171.                                        'ä',
  172.                                        'ã',
  173.                                        'å',
  174.                                        'ç',
  175.                                        'é',
  176.                                        'è',
  177.                                        'ê',
  178.                                        'ë',
  179.                                        'í',
  180.                                        'ì',
  181.                                        'î',
  182.                                        'ï',
  183.                                        'ñ',
  184.                                        'ó',
  185.                                        'ò',
  186.                                        'ô',
  187.                                        'ö',
  188.                                        'õ',
  189.                                        'ú',
  190.                                        'ù',
  191.                                        'û',
  192.                                        'ü',
  193.                                        'ý',
  194.                                        'ÿ' ], [ 'a',
  195.                                                 'a',
  196.                                                 'a',
  197.                                                 'a',
  198.                                                 'a',
  199.                                                 'a',
  200.                                                 'c',
  201.                                                 'e',
  202.                                                 'e',
  203.                                                 'e',
  204.                                                 'e',
  205.                                                 'i',
  206.                                                 'i',
  207.                                                 'i',
  208.                                                 'i',
  209.                                                 'n',
  210.                                                 'o',
  211.                                                 'o',
  212.                                                 'o',
  213.                                                 'o',
  214.                                                 'o',
  215.                                                 'u',
  216.                                                 'u',
  217.                                                 'u',
  218.                                                 'u',
  219.                                                 'y',
  220.                                                 'y' ], $username );
  221.             $username str_replace( [ ' ''' ], ''$username );
  222.             return filter_varstrtolower$username ), FILTER_SANITIZE_STRINGFILTER_FLAG_STRIP_LOW );
  223.         }
  224.         public function getName(): string
  225.         {
  226.             return trim$this->firstName " " $this->lastName );
  227.         }
  228.         /*
  229.          * ============================================================================================
  230.          * ============================== FIN FONCTIONS CUSTOM ========================================
  231.          * ============================================================================================
  232.          */
  233.         public function getId(): ?int
  234.         {
  235.             return $this->id;
  236.         }
  237.         public function getCivility(): ?string
  238.         {
  239.             return $this->civility;
  240.         }
  241.         public function setCivilitystring $civility ): self
  242.         {
  243.             $this->civility $civility;
  244.             return $this;
  245.         }
  246.         public function getLastName(): ?string
  247.         {
  248.             return $this->lastName;
  249.         }
  250.         public function setLastNamestring $lastName ): self
  251.         {
  252.             $this->lastName $lastName;
  253.             return $this;
  254.         }
  255.         public function getFirstName(): ?string
  256.         {
  257.             return $this->firstName;
  258.         }
  259.         public function setFirstNamestring $firstName ): self
  260.         {
  261.             $this->firstName $firstName;
  262.             return $this;
  263.         }
  264.         public function getCompany(): ?string
  265.         {
  266.             return $this->company;
  267.         }
  268.         public function setCompany( ?string $company ): self
  269.         {
  270.             $this->company $company;
  271.             return $this;
  272.         }
  273.         public function getEmail(): ?string
  274.         {
  275.             return $this->email;
  276.         }
  277.         public function setEmail( ?string $email ): self
  278.         {
  279.             $this->email $email;
  280.             return $this;
  281.         }
  282.         public function getAddress1(): ?string
  283.         {
  284.             return $this->address1;
  285.         }
  286.         public function setAddress1string $address1 ): self
  287.         {
  288.             $this->address1 $address1;
  289.             return $this;
  290.         }
  291.         public function getAddress2(): ?string
  292.         {
  293.             return $this->address2;
  294.         }
  295.         public function setAddress2( ?string $address2 ): self
  296.         {
  297.             $this->address2 $address2;
  298.             return $this;
  299.         }
  300.         public function getZipcode(): ?string
  301.         {
  302.             return $this->zipcode;
  303.         }
  304.         public function setZipcodestring $zipcode ): self
  305.         {
  306.             $this->zipcode $zipcode;
  307.             return $this;
  308.         }
  309.         public function getCity(): ?string
  310.         {
  311.             return $this->city;
  312.         }
  313.         public function setCitystring $city ): self
  314.         {
  315.             $this->city $city;
  316.             return $this;
  317.         }
  318.         public function getCountry(): ?string
  319.         {
  320.             return $this->country;
  321.         }
  322.         public function setCountrystring $country ): self
  323.         {
  324.             $this->country $country;
  325.             return $this;
  326.         }
  327.         public function getPhone(): ?string
  328.         {
  329.             return $this->phone;
  330.         }
  331.         public function setPhonestring $phone ): self
  332.         {
  333.             $this->phone $phone;
  334.             return $this;
  335.         }
  336.         public function getPoints(): ?int
  337.         {
  338.             return $this->points;
  339.         }
  340.         public function setPointsint $points ): self
  341.         {
  342.             $this->points $points;
  343.             return $this;
  344.         }
  345.         public function getStatus(): ?string
  346.         {
  347.             return $this->status;
  348.         }
  349.         public function setStatusstring $status ): self
  350.         {
  351.             $this->status $status;
  352.             return $this;
  353.         }
  354.         public function getUser(): ?User
  355.         {
  356.             return $this->user;
  357.         }
  358.         public function setUser( ?User $user ): self
  359.         {
  360.             $this->user $user;
  361.             return $this;
  362.         }
  363.         public function getReason(): ?string
  364.         {
  365.             return $this->reason;
  366.         }
  367.         public function setReason( ?string $reason ): self
  368.         {
  369.             $this->reason $reason;
  370.             return $this;
  371.         }
  372.         public function getIdentifier(): ?string
  373.         {
  374.             return $this->identifier;
  375.         }
  376.         public function setIdentifier( ?string $identifier ): self
  377.         {
  378.             $this->identifier $identifier;
  379.             return $this;
  380.         }
  381.     }