<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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