<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for JP_PackageDailyProductType StructType
 * @subpackage Structs
 */
class JP_PackageDailyProductType extends AbstractStructBase
{
    /**
     * The ProductType
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var string[]
     */
    public $ProductType;
    /**
     * The Day
     * @var string
     */
    public $Day;
    /**
     * Constructor method for JP_PackageDailyProductType
     * @uses JP_PackageDailyProductType::setProductType()
     * @uses JP_PackageDailyProductType::setDay()
     * @param string[] $productType
     * @param string $day
     */
    public function __construct(array $productType = array(), $day = null)
    {
        $this
            ->setProductType($productType)
            ->setDay($day);
    }
    /**
     * Get ProductType value
     * @return string[]|null
     */
    public function getProductType()
    {
        return $this->ProductType;
    }
    /**
     * This method is responsible for validating the values passed to the setProductType method
     * This method is willingly generated in order to preserve the one-line inline validation within the setProductType method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateProductTypeForArrayConstraintsFromSetProductType(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $jP_PackageDailyProductTypeProductTypeItem) {
            // validation for constraint: enumeration
            if (!\EnumType\JP_ProductType::valueIsValid($jP_PackageDailyProductTypeProductTypeItem)) {
                $invalidValues[] = is_object($jP_PackageDailyProductTypeProductTypeItem) ? get_class($jP_PackageDailyProductTypeProductTypeItem) : sprintf('%s(%s)', gettype($jP_PackageDailyProductTypeProductTypeItem), var_export($jP_PackageDailyProductTypeProductTypeItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \EnumType\JP_ProductType', is_array($invalidValues) ? implode(', ', $invalidValues) : var_export($invalidValues, true), implode(', ', \EnumType\JP_ProductType::getValidValues()));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set ProductType value
     * @uses \EnumType\JP_ProductType::valueIsValid()
     * @uses \EnumType\JP_ProductType::getValidValues()
     * @throws \InvalidArgumentException
     * @param string[] $productType
     * @return \StructType\JP_PackageDailyProductType
     */
    public function setProductType(array $productType = array())
    {
        // validation for constraint: array
        if ('' !== ($productTypeArrayErrorMessage = self::validateProductTypeForArrayConstraintsFromSetProductType($productType))) {
            throw new \InvalidArgumentException($productTypeArrayErrorMessage, __LINE__);
        }
        $this->ProductType = $productType;
        return $this;
    }
    /**
     * Add item to ProductType value
     * @uses \EnumType\JP_ProductType::valueIsValid()
     * @uses \EnumType\JP_ProductType::getValidValues()
     * @throws \InvalidArgumentException
     * @param string $item
     * @return \StructType\JP_PackageDailyProductType
     */
    public function addToProductType($item)
    {
        // validation for constraint: enumeration
        if (!\EnumType\JP_ProductType::valueIsValid($item)) {
            throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \EnumType\JP_ProductType', is_array($item) ? implode(', ', $item) : var_export($item, true), implode(', ', \EnumType\JP_ProductType::getValidValues())), __LINE__);
        }
        $this->ProductType[] = $item;
        return $this;
    }
    /**
     * Get Day value
     * @return string|null
     */
    public function getDay()
    {
        return $this->Day;
    }
    /**
     * Set Day value
     * @param string $day
     * @return \StructType\JP_PackageDailyProductType
     */
    public function setDay($day = null)
    {
        // validation for constraint: string
        if (!is_null($day) && !is_string($day)) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($day, true), gettype($day)), __LINE__);
        }
        $this->Day = $day;
        return $this;
    }
}
