<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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