<?php

namespace ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

/**
 * This class stands for ArrayOfJP_CarFee ArrayType
 * @subpackage Arrays
 */
class ArrayOfJP_CarFee extends AbstractStructArrayBase
{
    /**
     * The CarFee
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\JP_CarFee[]
     */
    public $CarFee;
    /**
     * Constructor method for ArrayOfJP_CarFee
     * @uses ArrayOfJP_CarFee::setCarFee()
     * @param \StructType\JP_CarFee[] $carFee
     */
    public function __construct(array $carFee = array())
    {
        $this
            ->setCarFee($carFee);
    }
    /**
     * Get CarFee value
     * @return \StructType\JP_CarFee[]|null
     */
    public function getCarFee()
    {
        return $this->CarFee;
    }
    /**
     * This method is responsible for validating the values passed to the setCarFee method
     * This method is willingly generated in order to preserve the one-line inline validation within the setCarFee method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateCarFeeForArrayConstraintsFromSetCarFee(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $arrayOfJP_CarFeeCarFeeItem) {
            // validation for constraint: itemType
            if (!$arrayOfJP_CarFeeCarFeeItem instanceof \StructType\JP_CarFee) {
                $invalidValues[] = is_object($arrayOfJP_CarFeeCarFeeItem) ? get_class($arrayOfJP_CarFeeCarFeeItem) : sprintf('%s(%s)', gettype($arrayOfJP_CarFeeCarFeeItem), var_export($arrayOfJP_CarFeeCarFeeItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The CarFee property can only contain items of type \StructType\JP_CarFee, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set CarFee value
     * @throws \InvalidArgumentException
     * @param \StructType\JP_CarFee[] $carFee
     * @return \ArrayType\ArrayOfJP_CarFee
     */
    public function setCarFee(array $carFee = array())
    {
        // validation for constraint: array
        if ('' !== ($carFeeArrayErrorMessage = self::validateCarFeeForArrayConstraintsFromSetCarFee($carFee))) {
            throw new \InvalidArgumentException($carFeeArrayErrorMessage, __LINE__);
        }
        $this->CarFee = $carFee;
        return $this;
    }
    /**
     * Add item to CarFee value
     * @throws \InvalidArgumentException
     * @param \StructType\JP_CarFee $item
     * @return \ArrayType\ArrayOfJP_CarFee
     */
    public function addToCarFee(\StructType\JP_CarFee $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\JP_CarFee) {
            throw new \InvalidArgumentException(sprintf('The CarFee property can only contain items of type \StructType\JP_CarFee, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->CarFee[] = $item;
        return $this;
    }
    /**
     * Returns the current element
     * @see AbstractStructArrayBase::current()
     * @return \StructType\JP_CarFee|null
     */
    public function current()
    {
        return parent::current();
    }
    /**
     * Returns the indexed element
     * @see AbstractStructArrayBase::item()
     * @param int $index
     * @return \StructType\JP_CarFee|null
     */
    public function item($index)
    {
        return parent::item($index);
    }
    /**
     * Returns the first element
     * @see AbstractStructArrayBase::first()
     * @return \StructType\JP_CarFee|null
     */
    public function first()
    {
        return parent::first();
    }
    /**
     * Returns the last element
     * @see AbstractStructArrayBase::last()
     * @return \StructType\JP_CarFee|null
     */
    public function last()
    {
        return parent::last();
    }
    /**
     * Returns the element at the offset
     * @see AbstractStructArrayBase::offsetGet()
     * @param int $offset
     * @return \StructType\JP_CarFee|null
     */
    public function offsetGet($offset)
    {
        return parent::offsetGet($offset);
    }
    /**
     * Returns the attribute name
     * @see AbstractStructArrayBase::getAttributeName()
     * @return string CarFee
     */
    public function getAttributeName()
    {
        return 'CarFee';
    }
}
