<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Background_Check_Package_Request_ReferencesType StructType
 * Meta information extracted from the WSDL
 * - documentation: Contains Background Check Package references
 * @subpackage Structs
 */
class Background_Check_Package_Request_ReferencesType extends AbstractStructBase
{
    /**
     * The Background_Check_Package_Reference
     * Meta information extracted from the WSDL
     * - documentation: Background Check Package references
     * - maxOccurs: unbounded
     * @var \StructType\Background_Check_PackageObjectType[]
     */
    public $Background_Check_Package_Reference;
    /**
     * Constructor method for Background_Check_Package_Request_ReferencesType
     * @uses Background_Check_Package_Request_ReferencesType::setBackground_Check_Package_Reference()
     * @param \StructType\Background_Check_PackageObjectType[] $background_Check_Package_Reference
     */
    public function __construct(array $background_Check_Package_Reference = array())
    {
        $this
            ->setBackground_Check_Package_Reference($background_Check_Package_Reference);
    }
    /**
     * Get Background_Check_Package_Reference value
     * @return \StructType\Background_Check_PackageObjectType[]|null
     */
    public function getBackground_Check_Package_Reference()
    {
        return $this->Background_Check_Package_Reference;
    }
    /**
     * This method is responsible for validating the values passed to the setBackground_Check_Package_Reference method
     * This method is willingly generated in order to preserve the one-line inline validation within the setBackground_Check_Package_Reference method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateBackground_Check_Package_ReferenceForArrayConstraintsFromSetBackground_Check_Package_Reference(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $background_Check_Package_Request_ReferencesTypeBackground_Check_Package_ReferenceItem) {
            // validation for constraint: itemType
            if (!$background_Check_Package_Request_ReferencesTypeBackground_Check_Package_ReferenceItem instanceof \StructType\Background_Check_PackageObjectType) {
                $invalidValues[] = is_object($background_Check_Package_Request_ReferencesTypeBackground_Check_Package_ReferenceItem) ? get_class($background_Check_Package_Request_ReferencesTypeBackground_Check_Package_ReferenceItem) : sprintf('%s(%s)', gettype($background_Check_Package_Request_ReferencesTypeBackground_Check_Package_ReferenceItem), var_export($background_Check_Package_Request_ReferencesTypeBackground_Check_Package_ReferenceItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Background_Check_Package_Reference property can only contain items of type \StructType\Background_Check_PackageObjectType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Background_Check_Package_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Background_Check_PackageObjectType[] $background_Check_Package_Reference
     * @return \StructType\Background_Check_Package_Request_ReferencesType
     */
    public function setBackground_Check_Package_Reference(array $background_Check_Package_Reference = array())
    {
        // validation for constraint: array
        if ('' !== ($background_Check_Package_ReferenceArrayErrorMessage = self::validateBackground_Check_Package_ReferenceForArrayConstraintsFromSetBackground_Check_Package_Reference($background_Check_Package_Reference))) {
            throw new \InvalidArgumentException($background_Check_Package_ReferenceArrayErrorMessage, __LINE__);
        }
        $this->Background_Check_Package_Reference = $background_Check_Package_Reference;
        return $this;
    }
    /**
     * Add item to Background_Check_Package_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Background_Check_PackageObjectType $item
     * @return \StructType\Background_Check_Package_Request_ReferencesType
     */
    public function addToBackground_Check_Package_Reference(\StructType\Background_Check_PackageObjectType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Background_Check_PackageObjectType) {
            throw new \InvalidArgumentException(sprintf('The Background_Check_Package_Reference property can only contain items of type \StructType\Background_Check_PackageObjectType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Background_Check_Package_Reference[] = $item;
        return $this;
    }
}
