<?php
namespace App\Utils\BaseParser\Structure\StructureParser\Types; abstract class PriceFormOfPayment extends \App\Utils\BaseParser\Structure\StructureParser\Types\BaseAbstract { public $components = []; public function append(\App\Utils\BaseParser\Structure\StructureParser\Types\PriceFormOfPaymentComponent $component) { $this->components[] = $component; return $this; } public function getShortNotation() { $return = []; foreach ($this->components as $comp) { $return[] = $comp->type; } sort($return); $return = array_unique($return); return implode("+", $return); } public function isPaidWith($paymentType) { foreach ($this->components as $comp) { if ($comp->type==$paymentType) { return true; } } return false; } public function getPaymentByType($paymentType, $index=null) { $return = []; foreach ($this->components as $comp) { if ($comp->type==$paymentType) { $return[] = $comp; } } if ($index===null) { return $return; } return $return[$index]; } } 