/** * Set the attribute value (and infer the type automatically). * * @param $value */ public function setValue($values) { if (!is_array($values)) { $values = [$values]; } if (count($values) === 0 || is_null(reset($values))) { return; } $this->type = Xml::attributeType(reset($values)); $this->value = []; foreach ($values as $value) { if ('DATE' === $this->type && !Date::isEmpty($value)) { $value = Date::format($value); } $this->value[] = $value; } }
/** * Set the attribute value (and infer the type automatically). * * @param $value */ public function setValue($value) { $type = Xml::attributeType($value); if ('DATE' === $type && !Date::isEmpty($value)) { $value = Date::format($value); } $this->value = $value; $this->type = $type; }
/** * Add a preferred distributor. * * @param $rank * @param $legacyDistributorId * @param null $from * @param null $till */ public function addPreferredDistributor($rank, $legacyDistributorId, $from = null, $till = null) { $this->preferredDistributors[] = ['legacyDistributorId' => $legacyDistributorId, 'effectiveFrom' => !Date::isEmpty($from) ? Date::format($from) : null, 'effectiveTill' => !Date::isEmpty($till) ? Date::format($till) : null, 'rank' => !is_null($rank) ? (int) $rank : null]; }
/** * If an end date isn't provided, a default (@see Pangaea::SPEC_DEFAULT_END_DATE) is used instead. * * @param $start * @param null $end */ public function setDates($start, $end = null) { $start = Date::isEmpty($start) ? '' : '<startDate>' . Date::format($start) . '</startDate>'; $end = Date::format(Date::isEmpty($end) ? Pangaea::SPEC_DEFAULT_END_DATE : $end); $this->dates = "{$start}<endDate>{$end}</endDate>"; }