I'm trying to improve my OOP code and I think my User class is becoming way too fat.
In my program a user has rights over "lists". Read, Write, Update, Delete. So I made a User class
class User
{
protected $_id;
protected $_email;
protected $_username;
protected $_hashedPassword;
//...Various setters/getters
public function canRead(List $list){
//Database query verifies if user has READ rights
}
public function canUpdate(List $list){
//Database query verifies if user has UPDATE rights
}
//etc...
}
- Should canRead, canUpdate, canWrite, canDelete methods be moved to another class (UserAccessCheck or something...)?
- If not, should the actual SQL be moved into the List object (listCanBeReadByUser()) ?
List
contains? \$\endgroup\$