Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Personne
- {
- public $name;
- public $lastName;
- public $address;
- public $birthday;
- public $allInformation = [];
- /************** ****************/
- /************ Getter************/
- /************** ****************/
- public function name()
- {
- return $this->name;
- }
- public function lastName()
- {
- return $this->lastName;
- }
- public function address()
- {
- return $this->address;
- }
- public function birthday()
- {
- return $this->birthday;
- }
- /************** **************/
- /************ Setter***********/
- /************** **************/
- public function setName($name)
- {
- if(is_string($name)){
- $this->name = $name;
- }
- }
- public function setLastName($lastName)
- {
- if (is_string($lastName)) {
- $this->lastName = $lastName;
- }
- }
- public function setAddress($address)
- {
- if (is_string($address)) {
- $this->address = $address;
- }
- }
- public function setBirthday($birthday)
- {
- $this->birthday = $birthday;
- }
- /************** **************/
- /************ Method **********/
- /************** **************/
- public function allInformation()
- {
- $this->allInformation[$this->name] = $this->name;
- $this->allInformation[$this->lastName] = $this->lastName;
- $this->allInformation[$this->address] = $this->address;
- $this->allInformation[$this->birthday] = $this->birthday;
- return $this->allInformation;
- }
- public function age()
- {
- $am = explode('/', $this->birthday);
- $an = explode('/', date('d/m/Y'));
- if(($am[1] < $an[1]) || (($am[1] == $an[1]) && ($am[0] <= $an[0]))){
- return $an[2] - $am[2];
- }
- return $an[2] - $am[2] - 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement