createdAt = new \DateTimeImmutable('now'); $this->account = new Account(); $this->mainAddress = new NullAddress(); } /** * Get payments * * @return Payment[] * * @since 1.0.0 */ public function getPayments() : array { return $this->payments; } /** * Get payments * * @param int $type Payment type * * @return array * * @since 1.0.0 */ public function getPaymentsByType(int $type) : array { $payments = []; foreach ($this->payments as $payment) { if ($payment->type === $type) { $payments[] = $payment; } } return $payments; } /** * Add doc to item * * @param EditorDoc $note Note * * @return void * * @since 1.0.0 */ public function addNote(EditorDoc $note) : void { $this->notes[] = $note; } /** * Get notes * * @return EditorDoc[] * * @since 1.0.0 */ public function getNotes() : array { return $this->notes; } /** * Get addresses. * * @return array * * @since 1.0.0 */ public function getAddresses() : array { return $this->address; } /** * Add partner * * @param Account $partner Partner * * @return void * * @since 1.0.0 */ public function addPartner(Account $partner) : void { $this->partners[] = $partner; } /** * Get partners * * @return Account[] * * @since 1.0.0 */ public function getPartners() : array { return $this->partners; } /** * Get contacts. * * @return array * * @since 1.0.0 */ public function getContactElements() : array { return $this->contactElements; } /** * Order contact elements * * @param ContactElement $a Element * @param ContactElement $b Element * * @return int * * @since 1.0.0 */ private function orderContactElements(ContactElement $a, ContactElement $b) : int { return $a->order <=> $b->order; } /** * Get the main contact element by type * * @param int $type Contact element type * * @return ContactElement * * @since 1.0.0 */ public function getMainContactElement(int $type) : ContactElement { \uasort($this->contactElements, [$this, 'orderContactElements']); foreach ($this->contactElements as $element) { if ($element->type === $type) { return $element; } } return new NullContactElement(); } /** * Add contact element * * @param int|ContactElement $element Contact element * * @return void * * @since 1.0.0 */ public function addContactElement($element) : void { $this->contactElements[] = $element; } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'number' => $this->number, 'numberReverse' => $this->numberReverse, 'status' => $this->status, 'type' => $this->type, 'info' => $this->info, ]; } /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } use \Modules\Media\Models\MediaListTrait; use \Modules\Editor\Models\EditorDocListTrait; use \Modules\Attribute\Models\AttributeHolderTrait; }