<?php

namespace App\OfferProfileRules;

class Criterion_ItineraryServiceClassCode extends CriterionAbstract
{

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


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

		// check that at least one value set
		if (($this->operation=='equal' or $this->operation=='notEqual') and !$this->values) {
			$msgs->addWarning("No class code set.");
		}
		else {
			// check the empty values
			foreach($this->values as $elem) {
				if (!$elem) {
					$msgs->addWarning("You cannot set an empty service class code.");
				}
			}
		}
	}

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

}

