smsMessages = new ArrayCollection(); } /** * @return int */ public function getId(): int { return $this->id; } /** * @param int $id * @return User */ public function setId(int $id): User { $this->id = $id; return $this; } /** * @return string */ public function getName(): string { return $this->name; } /** * @param string $name * @return User */ public function setName(string $name): User { $this->name = $name; return $this; } /** * @return string */ public function getHashKey(): string { return $this->hashKey; } /** * @param string $hashKey * @return User */ public function setHashKey(string $hashKey): User { $this->hashKey = $hashKey; return $this; } /** * @return Sms[]|ArrayCollection */ public function getSmsMessages(): ?ArrayCollection { return $this->smsMessages; } /** * @param Sms[]|ArrayCollection $smsMessages * @return User */ public function setSmsMessages(?ArrayCollection $smsMessages): User { $this->smsMessages = $smsMessages; return $this; } public function addSmsMessage(Sms $sms): User { if(!$this->smsMessages->contains($sms)) { $this->smsMessages->add($sms); } return $this; } public function removeSmsMessage(Sms $sms): User{ if($this->smsMessages->contains($sms)) { $this->smsMessages->removeElement($sms); } return $this; } /** * Specify data which should be serialized to JSON * @link http://php.net/manual/en/jsonserializable.jsonserialize.php * @return mixed data which can be serialized by json_encode, * which is a value of any type other than a resource. * @since 5.4.0 */ public function jsonSerialize() { return [ 'id' => $this->getId(), 'name' => $this->getName(), // 'smsMessages' => $this->getSmsMessages()->getValues(), ]; } }