pdo->query($this->findSql, $id); } } class PageService{ protected $db; function __construct(PageGateway $db){ $this->db = $db; } function findPage($id, $user){ $result = $this->db->find($id); if ($result['status'] === 'private' && $result['user_id'] != $user){ return null; } return $result; } }