src/Entity/Prediction.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PredictionRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity(repositoryClass=PredictionRepository::class)
  7. */
  8. class Prediction
  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 $birthday;
  24. /**
  25. * @ORM\Column(type="datetime")
  26. */
  27. private $createdAt;
  28. /**
  29. * @ORM\Column(type="string", length=255, nullable=true)
  30. */
  31. private $email;
  32. public function __construct()
  33. {
  34. }
  35. public function getId(): ?int
  36. {
  37. return $this->id;
  38. }
  39. public function getName(): ?string
  40. {
  41. return $this->name;
  42. }
  43. public function setName(?string $name): self
  44. {
  45. $this->name = $name;
  46. return $this;
  47. }
  48. public function getBirthday(): ?\DateTimeInterface
  49. {
  50. return $this->birthday;
  51. }
  52. public function setBirthday(\DateTimeInterface $birthday): self
  53. {
  54. $this->birthday = $birthday;
  55. return $this;
  56. }
  57. public function getCreatedAt(): ?\DateTimeInterface
  58. {
  59. return $this->createdAt;
  60. }
  61. public function setCreatedAt(\DateTimeInterface $createdAt): self
  62. {
  63. $this->createdAt = $createdAt;
  64. return $this;
  65. }
  66. public function getDigit(){
  67. return $this->sumDigits($this->getBirthday()->format('dm').date('Y'));
  68. }
  69. function sumDigits($number) {
  70. $result = 0;
  71. for($i=0; $i<strlen($number); $i++){
  72. $result += intval($number[$i]);
  73. }
  74. if($result >= 10) return $this->sumDigits($result.'');
  75. return $result;
  76. }
  77. public function getEmail(): ?string
  78. {
  79. return $this->email;
  80. }
  81. public function setEmail(?string $email): self
  82. {
  83. $this->email = $email;
  84. return $this;
  85. }
  86. }