update deps & install rector

This commit is contained in:
Dominik Liebler
2019-12-14 12:50:05 +01:00
parent 04acce6759
commit 579a5ac946
87 changed files with 2432 additions and 786 deletions

View File

@@ -2,16 +2,12 @@
namespace DesignPatterns\Structural\DataMapper;
use InvalidArgumentException;
class UserMapper
{
/**
* @var StorageAdapter
*/
private $adapter;
private StorageAdapter $adapter;
/**
* @param StorageAdapter $storage
*/
public function __construct(StorageAdapter $storage)
{
$this->adapter = $storage;
@@ -22,17 +18,13 @@ class UserMapper
* in memory. Normally this kind of logic will be implemented using the Repository pattern.
* However the important part is in mapRowToUser() below, that will create a business object from the
* data fetched from storage
*
* @param int $id
*
* @return User
*/
public function findById(int $id): User
{
$result = $this->adapter->find($id);
if ($result === null) {
throw new \InvalidArgumentException("User #$id not found");
throw new InvalidArgumentException("User #$id not found");
}
return $this->mapRowToUser($result);