<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Worktag_Split_Template_Criteria_Request_ReferencesType
 * StructType
 * Meta information extracted from the WSDL
 * - documentation: Element containing reference instances for a Worktag Split Template
 * @subpackage Structs
 */
class Worktag_Split_Template_Criteria_Request_ReferencesType extends AbstractStructBase
{
    /**
     * The Worktag_Split_Template_Restriction_Reference
     * Meta information extracted from the WSDL
     * - documentation: Reference to an existing Worktag Split Template
     * - maxOccurs: unbounded
     * @var \StructType\Worktag_Split_Template_CriteriaObjectType[]
     */
    public $Worktag_Split_Template_Restriction_Reference;
    /**
     * Constructor method for Worktag_Split_Template_Criteria_Request_ReferencesType
     * @uses Worktag_Split_Template_Criteria_Request_ReferencesType::setWorktag_Split_Template_Restriction_Reference()
     * @param \StructType\Worktag_Split_Template_CriteriaObjectType[] $worktag_Split_Template_Restriction_Reference
     */
    public function __construct(array $worktag_Split_Template_Restriction_Reference = array())
    {
        $this
            ->setWorktag_Split_Template_Restriction_Reference($worktag_Split_Template_Restriction_Reference);
    }
    /**
     * Get Worktag_Split_Template_Restriction_Reference value
     * @return \StructType\Worktag_Split_Template_CriteriaObjectType[]|null
     */
    public function getWorktag_Split_Template_Restriction_Reference()
    {
        return $this->Worktag_Split_Template_Restriction_Reference;
    }
    /**
     * This method is responsible for validating the values passed to the setWorktag_Split_Template_Restriction_Reference method
     * This method is willingly generated in order to preserve the one-line inline validation within the setWorktag_Split_Template_Restriction_Reference method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateWorktag_Split_Template_Restriction_ReferenceForArrayConstraintsFromSetWorktag_Split_Template_Restriction_Reference(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $worktag_Split_Template_Criteria_Request_ReferencesTypeWorktag_Split_Template_Restriction_ReferenceItem) {
            // validation for constraint: itemType
            if (!$worktag_Split_Template_Criteria_Request_ReferencesTypeWorktag_Split_Template_Restriction_ReferenceItem instanceof \StructType\Worktag_Split_Template_CriteriaObjectType) {
                $invalidValues[] = is_object($worktag_Split_Template_Criteria_Request_ReferencesTypeWorktag_Split_Template_Restriction_ReferenceItem) ? get_class($worktag_Split_Template_Criteria_Request_ReferencesTypeWorktag_Split_Template_Restriction_ReferenceItem) : sprintf('%s(%s)', gettype($worktag_Split_Template_Criteria_Request_ReferencesTypeWorktag_Split_Template_Restriction_ReferenceItem), var_export($worktag_Split_Template_Criteria_Request_ReferencesTypeWorktag_Split_Template_Restriction_ReferenceItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Worktag_Split_Template_Restriction_Reference property can only contain items of type \StructType\Worktag_Split_Template_CriteriaObjectType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Worktag_Split_Template_Restriction_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Worktag_Split_Template_CriteriaObjectType[] $worktag_Split_Template_Restriction_Reference
     * @return \StructType\Worktag_Split_Template_Criteria_Request_ReferencesType
     */
    public function setWorktag_Split_Template_Restriction_Reference(array $worktag_Split_Template_Restriction_Reference = array())
    {
        // validation for constraint: array
        if ('' !== ($worktag_Split_Template_Restriction_ReferenceArrayErrorMessage = self::validateWorktag_Split_Template_Restriction_ReferenceForArrayConstraintsFromSetWorktag_Split_Template_Restriction_Reference($worktag_Split_Template_Restriction_Reference))) {
            throw new \InvalidArgumentException($worktag_Split_Template_Restriction_ReferenceArrayErrorMessage, __LINE__);
        }
        $this->Worktag_Split_Template_Restriction_Reference = $worktag_Split_Template_Restriction_Reference;
        return $this;
    }
    /**
     * Add item to Worktag_Split_Template_Restriction_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Worktag_Split_Template_CriteriaObjectType $item
     * @return \StructType\Worktag_Split_Template_Criteria_Request_ReferencesType
     */
    public function addToWorktag_Split_Template_Restriction_Reference(\StructType\Worktag_Split_Template_CriteriaObjectType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Worktag_Split_Template_CriteriaObjectType) {
            throw new \InvalidArgumentException(sprintf('The Worktag_Split_Template_Restriction_Reference property can only contain items of type \StructType\Worktag_Split_Template_CriteriaObjectType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Worktag_Split_Template_Restriction_Reference[] = $item;
        return $this;
    }
}
