<?php

namespace hp_;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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