Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <?php
  2.  
  3. class Personne
  4. {
  5. public $name;
  6. public $lastName;
  7. public $address;
  8. public $birthday;
  9. public $allInformation = [];
  10.  
  11. /************** ****************/
  12. /************ Getter************/
  13. /************** ****************/
  14.  
  15. public function name()
  16. {
  17. return $this->name;
  18. }
  19.  
  20. public function lastName()
  21. {
  22. return $this->lastName;
  23. }
  24.  
  25. public function address()
  26. {
  27. return $this->address;
  28. }
  29.  
  30. public function birthday()
  31. {
  32. return $this->birthday;
  33. }
  34.  
  35. /************** **************/
  36. /************ Setter***********/
  37. /************** **************/
  38. public function setName($name)
  39. {
  40. if(is_string($name)){
  41.  
  42. $this->name = $name;
  43. }
  44.  
  45. }
  46.  
  47. public function setLastName($lastName)
  48. {
  49. if (is_string($lastName)) {
  50.  
  51. $this->lastName = $lastName;
  52.  
  53. }
  54. }
  55.  
  56. public function setAddress($address)
  57. {
  58. if (is_string($address)) {
  59.  
  60. $this->address = $address;
  61.  
  62. }
  63. }
  64.  
  65. public function setBirthday($birthday)
  66. {
  67. $this->birthday = $birthday;
  68.  
  69. }
  70.  
  71. /************** **************/
  72. /************ Method **********/
  73. /************** **************/
  74. public function allInformation()
  75. {
  76. $this->allInformation[$this->name] = $this->name;
  77. $this->allInformation[$this->lastName] = $this->lastName;
  78. $this->allInformation[$this->address] = $this->address;
  79. $this->allInformation[$this->birthday] = $this->birthday;
  80.  
  81. return $this->allInformation;
  82. }
  83.  
  84. public function age()
  85. {
  86. $am = explode('/', $this->birthday);
  87. $an = explode('/', date('d/m/Y'));
  88.  
  89. if(($am[1] < $an[1]) || (($am[1] == $an[1]) && ($am[0] <= $an[0]))){
  90.  
  91. return $an[2] - $am[2];
  92. }
  93. return $an[2] - $am[2] - 1;
  94. }
  95.  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement