<?php

namespace hp_;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for THpSvcWTableauDates StructType
 * @subpackage Structs
 */
class THpSvcWTableauDates extends AbstractStructBase
{
    /**
     * The date
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var string[]
     */
    public $date;
    /**
     * Constructor method for THpSvcWTableauDates
     * @uses THpSvcWTableauDates::setDate()
     * @param string[] $date
     */
    public function __construct(array $date = array())
    {
        $this
            ->setDate($date);
    }
    /**
     * Get date value
     * @return string[]|null
     */
    public function getDate()
    {
        return $this->date;
    }
    /**
     * This method is responsible for validating the values passed to the setDate method
     * This method is willingly generated in order to preserve the one-line inline validation within the setDate method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateDateForArrayConstraintsFromSetDate(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $tHpSvcWTableauDatesDateItem) {
            // validation for constraint: itemType
            if (!is_string($tHpSvcWTableauDatesDateItem)) {
                $invalidValues[] = is_object($tHpSvcWTableauDatesDateItem) ? get_class($tHpSvcWTableauDatesDateItem) : sprintf('%s(%s)', gettype($tHpSvcWTableauDatesDateItem), var_export($tHpSvcWTableauDatesDateItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The date property can only contain items of type date, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set date value
     * @throws \InvalidArgumentException
     * @param string[] $date
     * @return \hp_\THpSvcWTableauDates
     */
    public function setDate(array $date = array())
    {
        // validation for constraint: array
        if ('' !== ($dateArrayErrorMessage = self::validateDateForArrayConstraintsFromSetDate($date))) {
            throw new \InvalidArgumentException($dateArrayErrorMessage, __LINE__);
        }
        $this->date = $date;
        return $this;
    }
    /**
     * Add item to date value
     * @throws \InvalidArgumentException
     * @param string $item
     * @return \hp_\THpSvcWTableauDates
     */
    public function addToDate($item)
    {
        // validation for constraint: itemType
        if (!is_string($item)) {
            throw new \InvalidArgumentException(sprintf('The date property can only contain items of type date, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->date[] = $item;
        return $this;
    }
}
