<?php

namespace hp_;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for THpSvcWTableauSemaines StructType
 * @subpackage Structs
 */
class THpSvcWTableauSemaines extends AbstractStructBase
{
    /**
     * The THpSvcWSemaine
     * Meta information extracted from the WSDL
     * - base: xsd:unsignedShort
     * - maxInclusive: 52
     * - maxOccurs: unbounded
     * - minInclusive: 1
     * - minOccurs: 0
     * @var int[]
     */
    public $THpSvcWSemaine;
    /**
     * Constructor method for THpSvcWTableauSemaines
     * @uses THpSvcWTableauSemaines::setTHpSvcWSemaine()
     * @param int[] $tHpSvcWSemaine
     */
    public function __construct(array $tHpSvcWSemaine = array())
    {
        $this
            ->setTHpSvcWSemaine($tHpSvcWSemaine);
    }
    /**
     * Get THpSvcWSemaine value
     * @return int[]|null
     */
    public function getTHpSvcWSemaine()
    {
        return $this->THpSvcWSemaine;
    }
    /**
     * This method is responsible for validating the values passed to the setTHpSvcWSemaine method
     * This method is willingly generated in order to preserve the one-line inline validation within the setTHpSvcWSemaine method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateTHpSvcWSemaineForArrayConstraintsFromSetTHpSvcWSemaine(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $tHpSvcWTableauSemainesTHpSvcWSemaineItem) {
            // validation for constraint: itemType
            if (!(is_int($tHpSvcWTableauSemainesTHpSvcWSemaineItem) || ctype_digit($tHpSvcWTableauSemainesTHpSvcWSemaineItem))) {
                $invalidValues[] = is_object($tHpSvcWTableauSemainesTHpSvcWSemaineItem) ? get_class($tHpSvcWTableauSemainesTHpSvcWSemaineItem) : sprintf('%s(%s)', gettype($tHpSvcWTableauSemainesTHpSvcWSemaineItem), var_export($tHpSvcWTableauSemainesTHpSvcWSemaineItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The THpSvcWSemaine property can only contain items of type unsignedShort, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set THpSvcWSemaine value
     * @throws \InvalidArgumentException
     * @param int[] $tHpSvcWSemaine
     * @return \hp_\THpSvcWTableauSemaines
     */
    public function setTHpSvcWSemaine(array $tHpSvcWSemaine = array())
    {
        // validation for constraint: array
        if ('' !== ($tHpSvcWSemaineArrayErrorMessage = self::validateTHpSvcWSemaineForArrayConstraintsFromSetTHpSvcWSemaine($tHpSvcWSemaine))) {
            throw new \InvalidArgumentException($tHpSvcWSemaineArrayErrorMessage, __LINE__);
        }
        // validation for constraint: maxInclusive(52)
        if (!is_null($tHpSvcWSemaine) && $tHpSvcWSemaine > 52) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, the value must be numerically less than or equal to 52', var_export($tHpSvcWSemaine, true)), __LINE__);
        }
        // validation for constraint: minInclusive(1)
        if (!is_null($tHpSvcWSemaine) && $tHpSvcWSemaine < 1) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, the value must be numerically greater than or equal to 1', var_export($tHpSvcWSemaine, true)), __LINE__);
        }
        $this->THpSvcWSemaine = $tHpSvcWSemaine;
        return $this;
    }
    /**
     * Add item to THpSvcWSemaine value
     * @throws \InvalidArgumentException
     * @param int $item
     * @return \hp_\THpSvcWTableauSemaines
     */
    public function addToTHpSvcWSemaine($item)
    {
        // validation for constraint: itemType
        if (!(is_int($item) || ctype_digit($item))) {
            throw new \InvalidArgumentException(sprintf('The THpSvcWSemaine property can only contain items of type unsignedShort, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        // validation for constraint: maxInclusive(52)
        if ($item > 52) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, the value must be numerically less than or equal to 52', var_export($item, true)), __LINE__);
        }
        // validation for constraint: minInclusive(1)
        if ($item < 1) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, the value must be numerically greater than or equal to 1', var_export($item, true)), __LINE__);
        }
        $this->THpSvcWSemaine[] = $item;
        return $this;
    }
}
