I have a user model that has many properties such as first_name, last_name, email, address, address2 ... etc.
I am writing a php class to manage these properties, but it looks like I am writing a lot of the same code. (Getters and seters). Should I use magic methods to control this? This is similar to the idea of OK, but I do not want the wrong properties to be set. Any ideas?
<?php
class User
{
private $username;
private $email
private $first_name;
private $last_name;
private $address;
private $address2;
function __construct()
{
}
function getUsername()
{
return $this->username
}
function setUsername($username)
{
$this->username = $username;
}
...
}
?>
source
share