<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for EmployeeEmergencyContactList StructType
 * @subpackage Structs
 */
class EmployeeEmergencyContactList extends AbstractStructBase
{
    /**
     * The employeeEmergencyContact
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\EmployeeEmergencyContact[]
     */
    public $employeeEmergencyContact;
    /**
     * The replaceAll
     * Meta information extracted from the WSDL
     * - default: true
     * @var bool
     */
    public $replaceAll;
    /**
     * Constructor method for EmployeeEmergencyContactList
     * @uses EmployeeEmergencyContactList::setEmployeeEmergencyContact()
     * @uses EmployeeEmergencyContactList::setReplaceAll()
     * @param \StructType\EmployeeEmergencyContact[] $employeeEmergencyContact
     * @param bool $replaceAll
     */
    public function __construct(array $employeeEmergencyContact = array(), $replaceAll = true)
    {
        $this
            ->setEmployeeEmergencyContact($employeeEmergencyContact)
            ->setReplaceAll($replaceAll);
    }
    /**
     * Get employeeEmergencyContact value
     * @return \StructType\EmployeeEmergencyContact[]|null
     */
    public function getEmployeeEmergencyContact()
    {
        return $this->employeeEmergencyContact;
    }
    /**
     * This method is responsible for validating the values passed to the setEmployeeEmergencyContact method
     * This method is willingly generated in order to preserve the one-line inline validation within the setEmployeeEmergencyContact method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateEmployeeEmergencyContactForArrayConstraintsFromSetEmployeeEmergencyContact(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $employeeEmergencyContactListEmployeeEmergencyContactItem) {
            // validation for constraint: itemType
            if (!$employeeEmergencyContactListEmployeeEmergencyContactItem instanceof \StructType\EmployeeEmergencyContact) {
                $invalidValues[] = is_object($employeeEmergencyContactListEmployeeEmergencyContactItem) ? get_class($employeeEmergencyContactListEmployeeEmergencyContactItem) : sprintf('%s(%s)', gettype($employeeEmergencyContactListEmployeeEmergencyContactItem), var_export($employeeEmergencyContactListEmployeeEmergencyContactItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The employeeEmergencyContact property can only contain items of type \StructType\EmployeeEmergencyContact, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set employeeEmergencyContact value
     * @throws \InvalidArgumentException
     * @param \StructType\EmployeeEmergencyContact[] $employeeEmergencyContact
     * @return \StructType\EmployeeEmergencyContactList
     */
    public function setEmployeeEmergencyContact(array $employeeEmergencyContact = array())
    {
        // validation for constraint: array
        if ('' !== ($employeeEmergencyContactArrayErrorMessage = self::validateEmployeeEmergencyContactForArrayConstraintsFromSetEmployeeEmergencyContact($employeeEmergencyContact))) {
            throw new \InvalidArgumentException($employeeEmergencyContactArrayErrorMessage, __LINE__);
        }
        $this->employeeEmergencyContact = $employeeEmergencyContact;
        return $this;
    }
    /**
     * Add item to employeeEmergencyContact value
     * @throws \InvalidArgumentException
     * @param \StructType\EmployeeEmergencyContact $item
     * @return \StructType\EmployeeEmergencyContactList
     */
    public function addToEmployeeEmergencyContact(\StructType\EmployeeEmergencyContact $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\EmployeeEmergencyContact) {
            throw new \InvalidArgumentException(sprintf('The employeeEmergencyContact property can only contain items of type \StructType\EmployeeEmergencyContact, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->employeeEmergencyContact[] = $item;
        return $this;
    }
    /**
     * Get replaceAll value
     * @return bool|null
     */
    public function getReplaceAll()
    {
        return $this->replaceAll;
    }
    /**
     * Set replaceAll value
     * @param bool $replaceAll
     * @return \StructType\EmployeeEmergencyContactList
     */
    public function setReplaceAll($replaceAll = true)
    {
        // validation for constraint: boolean
        if (!is_null($replaceAll) && !is_bool($replaceAll)) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($replaceAll, true), gettype($replaceAll)), __LINE__);
        }
        $this->replaceAll = $replaceAll;
        return $this;
    }
}
