image = new NullMedia(); $this->parent = new NullUnit(); $this->mainAddress = new NullAddress(); } /** * Get id * * @return int * * @since 1.0.0 */ public function getId() : int { return $this->id; } /** * Add attribute to client * * @param UnitAttribute $attribute Attribute * * @return void * * @since 1.0.0 */ public function addAttribute(UnitAttribute $attribute) : void { $this->attributes[] = $attribute; } /** * Get attributes * * @return UnitAttribute[] * * @since 1.0.0 */ public function getAttributes() : array { return $this->attributes; } /** * Get attribute * * @param string $attrName Attribute name * * @return null|UnitAttribute * * @since 1.0.0 */ public function getAttribute(string $attrName) : ?UnitAttribute { foreach ($this->attributes as $attribute) { if ($attribute->type->name === $attrName) { return $attribute->value; } } return null; } /** * Get status * * @return int * * @since 1.0.0 */ public function getStatus() : int { return $this->status; } /** * Set status * * @param int $status Status * * @return void * * @since 1.0.0 */ public function setStatus(int $status) : void { $this->status = $status; } /** * Get addresses. * * @return array * * @since 1.0.0 */ public function getAddresses() : array { return $this->address; } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'name' => $this->name, 'status' => $this->status, 'description' => $this->description, 'descriptionRaw' => $this->descriptionRaw, 'parent' => $this->parent ?? null, 'image' => $this->image, ]; } /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } }