<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Payroll_Timesheet_Total_Hours_Request_ReferencesType
 * StructType
 * Meta information extracted from the WSDL
 * - documentation: This element is a wrapper containing references to Payroll Timesheet Total Hours.
 * @subpackage Structs
 */
class Payroll_Timesheet_Total_Hours_Request_ReferencesType extends AbstractStructBase
{
    /**
     * The Payroll_Timesheet_Total_Hours_Reference
     * Meta information extracted from the WSDL
     * - documentation: References to Payroll Timesheet Total Hours.
     * - maxOccurs: unbounded
     * @var \StructType\Payroll_Timesheet_Total_HoursObjectType[]
     */
    public $Payroll_Timesheet_Total_Hours_Reference;
    /**
     * Constructor method for Payroll_Timesheet_Total_Hours_Request_ReferencesType
     * @uses Payroll_Timesheet_Total_Hours_Request_ReferencesType::setPayroll_Timesheet_Total_Hours_Reference()
     * @param \StructType\Payroll_Timesheet_Total_HoursObjectType[] $payroll_Timesheet_Total_Hours_Reference
     */
    public function __construct(array $payroll_Timesheet_Total_Hours_Reference = array())
    {
        $this
            ->setPayroll_Timesheet_Total_Hours_Reference($payroll_Timesheet_Total_Hours_Reference);
    }
    /**
     * Get Payroll_Timesheet_Total_Hours_Reference value
     * @return \StructType\Payroll_Timesheet_Total_HoursObjectType[]|null
     */
    public function getPayroll_Timesheet_Total_Hours_Reference()
    {
        return $this->Payroll_Timesheet_Total_Hours_Reference;
    }
    /**
     * This method is responsible for validating the values passed to the setPayroll_Timesheet_Total_Hours_Reference method
     * This method is willingly generated in order to preserve the one-line inline validation within the setPayroll_Timesheet_Total_Hours_Reference method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validatePayroll_Timesheet_Total_Hours_ReferenceForArrayConstraintsFromSetPayroll_Timesheet_Total_Hours_Reference(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $payroll_Timesheet_Total_Hours_Request_ReferencesTypePayroll_Timesheet_Total_Hours_ReferenceItem) {
            // validation for constraint: itemType
            if (!$payroll_Timesheet_Total_Hours_Request_ReferencesTypePayroll_Timesheet_Total_Hours_ReferenceItem instanceof \StructType\Payroll_Timesheet_Total_HoursObjectType) {
                $invalidValues[] = is_object($payroll_Timesheet_Total_Hours_Request_ReferencesTypePayroll_Timesheet_Total_Hours_ReferenceItem) ? get_class($payroll_Timesheet_Total_Hours_Request_ReferencesTypePayroll_Timesheet_Total_Hours_ReferenceItem) : sprintf('%s(%s)', gettype($payroll_Timesheet_Total_Hours_Request_ReferencesTypePayroll_Timesheet_Total_Hours_ReferenceItem), var_export($payroll_Timesheet_Total_Hours_Request_ReferencesTypePayroll_Timesheet_Total_Hours_ReferenceItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Payroll_Timesheet_Total_Hours_Reference property can only contain items of type \StructType\Payroll_Timesheet_Total_HoursObjectType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Payroll_Timesheet_Total_Hours_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Payroll_Timesheet_Total_HoursObjectType[] $payroll_Timesheet_Total_Hours_Reference
     * @return \StructType\Payroll_Timesheet_Total_Hours_Request_ReferencesType
     */
    public function setPayroll_Timesheet_Total_Hours_Reference(array $payroll_Timesheet_Total_Hours_Reference = array())
    {
        // validation for constraint: array
        if ('' !== ($payroll_Timesheet_Total_Hours_ReferenceArrayErrorMessage = self::validatePayroll_Timesheet_Total_Hours_ReferenceForArrayConstraintsFromSetPayroll_Timesheet_Total_Hours_Reference($payroll_Timesheet_Total_Hours_Reference))) {
            throw new \InvalidArgumentException($payroll_Timesheet_Total_Hours_ReferenceArrayErrorMessage, __LINE__);
        }
        $this->Payroll_Timesheet_Total_Hours_Reference = $payroll_Timesheet_Total_Hours_Reference;
        return $this;
    }
    /**
     * Add item to Payroll_Timesheet_Total_Hours_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Payroll_Timesheet_Total_HoursObjectType $item
     * @return \StructType\Payroll_Timesheet_Total_Hours_Request_ReferencesType
     */
    public function addToPayroll_Timesheet_Total_Hours_Reference(\StructType\Payroll_Timesheet_Total_HoursObjectType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Payroll_Timesheet_Total_HoursObjectType) {
            throw new \InvalidArgumentException(sprintf('The Payroll_Timesheet_Total_Hours_Reference property can only contain items of type \StructType\Payroll_Timesheet_Total_HoursObjectType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Payroll_Timesheet_Total_Hours_Reference[] = $item;
        return $this;
    }
}
