*/ class User { /** * @var integer */ protected $id; /** * @var string */ protected $username; /** * @var array $votes; */ protected $votes = []; /** * @param int $id * @return User */ public function setId($id) { $this->id = (int) $id; return $this; } /** * @return int $id */ public function getId() { return $this->id; } /** * @param string $username * @return */ public function setUsername($username) { $this->username = (string) $username; return $this; } /** * @return string $username */ public function getUsername() { return $this->username; } /** * @param Vote $vote * @return Article */ public function addVote(Vote $vote) { $this->votes[] = $vote; return $this; } /** * @param array $votes * @return Article */ public function setVotes(array $votes) { foreach ($votes as $vote) { $vote->setUser($this); } $this->votes = $votes; return $this; } /** * @return array $votes */ public function getVotes() { $this->votes = VoteDao::create()->findByUser($this); return $this->votes; } }