Updated mapper with docblocs & removed unused (unreachable) code

This commit is contained in:
eddiejaoude
2013-08-31 10:04:48 +01:00
parent 4afe5a9e2d
commit 4d85355bd2

View File

@@ -26,6 +26,9 @@ namespace DesignPatterns\DataMapper;
class UserMapper class UserMapper
{ {
/**
* @var DBAL
*/
protected $_adapter; protected $_adapter;
public function __construct(DBAL $dbLayer) public function __construct(DBAL $dbLayer)
@@ -36,15 +39,16 @@ class UserMapper
/** /**
* saves a user object from memory to Database * saves a user object from memory to Database
* *
* @param User $user
* @return boolean * @return boolean
*/ */
public function save(User $user) public function save(User $user)
{ {
/* $data keys shoulds correspond to valid Table columns on the Database */ /* $data keys should correspond to valid Table columns on the Database */
$data = array( $data = array(
'userid' => $user->getUserId(), 'userid' => $user->getUserId(),
'username' => $user->getUsername(), 'username' => $user->getUsername(),
'email' => $user->getEmail(), 'email' => $user->getEmail(),
); );
/* if no ID specified create new user else update the one in the Database */ /* if no ID specified create new user else update the one in the Database */
@@ -56,14 +60,14 @@ class UserMapper
$this->_adapter->update($data, array('userid = ?' => $id)); $this->_adapter->update($data, array('userid = ?' => $id));
return true; return true;
} }
return false;
} }
/** /**
* finds a user from Database based on ID and returns a User object located * finds a user from Database based on ID and returns a User object located
* in memory * in memory
* *
* @param $id
* @throws \InvalidArgumentException
* @return User * @return User
*/ */
public function findById($id) public function findById($id)