<?php

namespace App\OfferProfileRules;

class Criterion_OfferAttribute_Multiplier extends CriterionAbstract
{

	/**
	 * (non-PHPdoc)
	 * @see \App\OfferProfileRules\CriterionAbstract::checkFields()
	 */
	public function checkFields(\App\OfferProfileRules\Fields $fields)
	{
		return $this->checkField($fields->offerProductMultiplier);
	}


	/**
	 * (non-PHPdoc)
	 * @see \App\OfferProfileRules\CriterionAbstract::checkAssignedValues()
	 */
	public function checkAssignedValues(\App\MessagesCollector $msgs)
	{

		if (!$this->values and in_array($this->operation, ['containsInclusive', 'containsExclusive', 'containsOne', 'containsNone'])) {
			$msgs->addWarning("No offer multiplier set.");
		}
		else {
			// check the empty values
			foreach($this->values as $multiplierCode) {
				if (!$multiplierCode) {
					$msgs->addWarning("You cannot set an empty multiplier code.");
				}
			}
		}

	}

	/**
	 * (non-PHPdoc)
	 * @see \App\OfferProfileRules\CriterionAbstract::createDescription_getEntityName()
	 */
	protected function createDescription_getEntityName($code)
	{
		return $code;
	}

}

