<?php

namespace Cocorico\EdnBundle\Wsdl;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for getShipmentsRequest StructType
 * @subpackage Structs
 */
class GetShipmentsRequest extends AbstractStructBase
{
    /**
     * The references
     * Meta information extracted from the WSDL
     * - arrayType: xsd:string[]
     * - base: SOAP-ENC:Array
     * - maxOccurs: 1
     * - minOccurs: 0
     * - ref: SOAP-ENC:arrayType
     * @var string[]
     */
    public $references;
    /**
     * The trackings
     * Meta information extracted from the WSDL
     * - arrayType: xsd:string[]
     * - base: SOAP-ENC:Array
     * - maxOccurs: 1
     * - minOccurs: 0
     * - ref: SOAP-ENC:arrayType
     * @var string[]
     */
    public $trackings;
    /**
     * Constructor method for getShipmentsRequest
     * @uses GetShipmentsRequest::setReferences()
     * @uses GetShipmentsRequest::setTrackings()
     * @param string[] $references
     * @param string[] $trackings
     */
    public function __construct(array $references = array(), array $trackings = array())
    {
        $this
            ->setReferences($references)
            ->setTrackings($trackings);
    }
    /**
     * Get references value
     * @return string[]|null
     */
    public function getReferences()
    {
        return $this->references;
    }
    /**
     * This method is responsible for validating the values passed to the setReferences method
     * This method is willingly generated in order to preserve the one-line inline validation within the setReferences method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateReferencesForArrayConstraintsFromSetReferences(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $getShipmentsRequestReferencesItem) {
            // validation for constraint: itemType
            if (!is_string($getShipmentsRequestReferencesItem)) {
                $invalidValues[] = is_object($getShipmentsRequestReferencesItem) ? get_class($getShipmentsRequestReferencesItem) : sprintf('%s(%s)', gettype($getShipmentsRequestReferencesItem), var_export($getShipmentsRequestReferencesItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The references property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set references value
     * @throws \InvalidArgumentException
     * @param string[] $references
     * @return \Cocorico\EdnBundle\Wsdl\GetShipmentsRequest
     */
    public function setReferences(array $references = array())
    {
        // validation for constraint: array
        if ('' !== ($referencesArrayErrorMessage = self::validateReferencesForArrayConstraintsFromSetReferences($references))) {
            throw new \InvalidArgumentException($referencesArrayErrorMessage, __LINE__);
        }
        // validation for constraint: maxOccurs(1)
        if (is_array($references) && count($references) > 1) {
            throw new \InvalidArgumentException(sprintf('Invalid count of %s, the number of elements contained by the property must be less than or equal to 1', count($references)), __LINE__);
        }
        $this->references = $references;
        return $this;
    }
    /**
     * Add item to references value
     * @throws \InvalidArgumentException
     * @param string $item
     * @return \Cocorico\EdnBundle\Wsdl\GetShipmentsRequest
     */
    public function addToReferences($item)
    {
        // validation for constraint: itemType
        if (!is_string($item)) {
            throw new \InvalidArgumentException(sprintf('The references property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        // validation for constraint: maxOccurs(1)
        if (is_array($this->references) && count($this->references) >= 1) {
            throw new \InvalidArgumentException(sprintf('You can\'t add anymore element to this property that already contains %s elements, the number of elements contained by the property must be less than or equal to 1', count($this->references)), __LINE__);
        }
        $this->references[] = $item;
        return $this;
    }
    /**
     * Get trackings value
     * @return string[]|null
     */
    public function getTrackings()
    {
        return $this->trackings;
    }
    /**
     * This method is responsible for validating the values passed to the setTrackings method
     * This method is willingly generated in order to preserve the one-line inline validation within the setTrackings method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateTrackingsForArrayConstraintsFromSetTrackings(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $getShipmentsRequestTrackingsItem) {
            // validation for constraint: itemType
            if (!is_string($getShipmentsRequestTrackingsItem)) {
                $invalidValues[] = is_object($getShipmentsRequestTrackingsItem) ? get_class($getShipmentsRequestTrackingsItem) : sprintf('%s(%s)', gettype($getShipmentsRequestTrackingsItem), var_export($getShipmentsRequestTrackingsItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The trackings property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set trackings value
     * @throws \InvalidArgumentException
     * @param string[] $trackings
     * @return \Cocorico\EdnBundle\Wsdl\GetShipmentsRequest
     */
    public function setTrackings(array $trackings = array())
    {
        // validation for constraint: array
        if ('' !== ($trackingsArrayErrorMessage = self::validateTrackingsForArrayConstraintsFromSetTrackings($trackings))) {
            throw new \InvalidArgumentException($trackingsArrayErrorMessage, __LINE__);
        }
        // validation for constraint: maxOccurs(1)
        if (is_array($trackings) && count($trackings) > 1) {
            throw new \InvalidArgumentException(sprintf('Invalid count of %s, the number of elements contained by the property must be less than or equal to 1', count($trackings)), __LINE__);
        }
        $this->trackings = $trackings;
        return $this;
    }
    /**
     * Add item to trackings value
     * @throws \InvalidArgumentException
     * @param string $item
     * @return \Cocorico\EdnBundle\Wsdl\GetShipmentsRequest
     */
    public function addToTrackings($item)
    {
        // validation for constraint: itemType
        if (!is_string($item)) {
            throw new \InvalidArgumentException(sprintf('The trackings property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        // validation for constraint: maxOccurs(1)
        if (is_array($this->trackings) && count($this->trackings) >= 1) {
            throw new \InvalidArgumentException(sprintf('You can\'t add anymore element to this property that already contains %s elements, the number of elements contained by the property must be less than or equal to 1', count($this->trackings)), __LINE__);
        }
        $this->trackings[] = $item;
        return $this;
    }
    /**
     * Method called when an object has been exported with var_export() functions
     * It allows to return an object instantiated with the values
     * @see AbstractStructBase::__set_state()
     * @uses AbstractStructBase::__set_state()
     * @param array $array the exported values
     * @return \Cocorico\EdnBundle\Wsdl\GetShipmentsRequest
     */
    public static function __set_state(array $array)
    {
        return parent::__set_state($array);
    }
    /**
     * Method returning the class name
     * @return string __CLASS__
     */
    public function __toString()
    {
        return __CLASS__;
    }
}
