52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
|
||
|
class User extends Model
|
||
|
{
|
||
|
private $data;
|
||
|
|
||
|
public function __construct($data = null)
|
||
|
{
|
||
|
parent::__construct();
|
||
|
$_col = get_class()::getColumns();
|
||
|
if($data !== null){
|
||
|
forEach($data as $key=>$value){
|
||
|
if(!key_exists($key, $_col)){
|
||
|
throw new Exception('Invalid data entry');
|
||
|
}else{
|
||
|
$this->data[$key] = $value;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return $this;
|
||
|
}
|
||
|
/*
|
||
|
* Getters
|
||
|
*/
|
||
|
public function getEmail(){
|
||
|
if(isset($this->data['email']))
|
||
|
return $this->data['email'];
|
||
|
return false;
|
||
|
}
|
||
|
public function getFirstName(){
|
||
|
if(isset($this->data['firstName']))
|
||
|
return $this->data['firstName'];
|
||
|
return false;
|
||
|
}
|
||
|
public function getLastName(){
|
||
|
if(isset($this->data['lastName']))
|
||
|
return $this->data['lastName'];
|
||
|
return false;
|
||
|
}
|
||
|
public function getPhoneNumber(){
|
||
|
if(isset($this->data['phoneNumber']))
|
||
|
return $this->data['phoneNumber'];
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public function isLoggedIn(){
|
||
|
return (isset($this->data['email']));
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|