- var_dump: documentation ( source)
<?php
class UserEntity{
protected $record = null;
public function __construct(array $record){
$this->record = $record;
}
public function getEMail(){
return $this->record['email'];
}
}
class UserRepository{
protected $pdo = null;
public function __construct(?PDO $pdo){
$this->pdo = $pdo;
}
public function byId(int $id){
//faking. should probably be moved to a ::make method or something.
return new UserEntity([
'name' => 'John',
'email' => 'blah@blah.com',
]);
}
public function add(UserEntity $user){
//...
}
}
$userRepository = new UserRepository(null);
$user = $userRepository->byId(34);
var_dump($user->getEMail());