<?php

namespace CfcalSasieSDK\Entity;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Emplois Entity
 * Meta information extracted from the WSDL
 * - nillable: true
 * - type: tns:Emplois
 * @subpackage Structs
 */
class Emplois extends AbstractStructBase
{
    /**
     * The Emploi
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var \CfcalSasieSDK\Entity\Emploi[]
     */
    public $Emploi;
    /**
     * Constructor method for Emplois
     * @uses Emplois::setEmploi()
     * @param \CfcalSasieSDK\Entity\Emploi[] $emploi
     */
    public function __construct(array $emploi = array())
    {
        $this
            ->setEmploi($emploi);
    }
    /**
     * Get Emploi value
     * An additional test has been added (isset) before returning the property value as
     * this property may have been unset before, due to the fact that this property is
     * removable from the request (nillable=true+minOccurs=0)
     * @return \CfcalSasieSDK\Entity\Emploi[]|null
     */
    public function getEmploi()
    {
        return isset($this->Emploi) ? $this->Emploi : null;
    }
    /**
     * This method is responsible for validating the values passed to the setEmploi method
     * This method is willingly generated in order to preserve the one-line inline validation within the setEmploi method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateEmploiForArrayConstraintsFromSetEmploi(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $emploisEmploiItem) {
            // validation for constraint: itemType
            if (!$emploisEmploiItem instanceof \CfcalSasieSDK\Entity\Emploi) {
                $invalidValues[] = is_object($emploisEmploiItem) ? get_class($emploisEmploiItem) : sprintf('%s(%s)', gettype($emploisEmploiItem), var_export($emploisEmploiItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Emploi property can only contain items of type \CfcalSasieSDK\Entity\Emploi, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Emploi value
     * This property is removable from request (nillable=true+minOccurs=0), therefore
     * if the value assigned to this property is null, it is removed from this object
     * @throws \InvalidArgumentException
     * @param \CfcalSasieSDK\Entity\Emploi[] $emploi
     * @return \CfcalSasieSDK\Entity\Emplois
     */
    public function setEmploi(array $emploi = array())
    {
        // validation for constraint: array
        if ('' !== ($emploiArrayErrorMessage = self::validateEmploiForArrayConstraintsFromSetEmploi($emploi))) {
            throw new \InvalidArgumentException($emploiArrayErrorMessage, __LINE__);
        }
        if (is_null($emploi) || (is_array($emploi) && empty($emploi))) {
            unset($this->Emploi);
        } else {
            $this->Emploi = $emploi;
        }
        return $this;
    }
    /**
     * Add item to Emploi value
     * @throws \InvalidArgumentException
     * @param \CfcalSasieSDK\Entity\Emploi $item
     * @return \CfcalSasieSDK\Entity\Emplois
     */
    public function addToEmploi(\CfcalSasieSDK\Entity\Emploi $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \CfcalSasieSDK\Entity\Emploi) {
            throw new \InvalidArgumentException(sprintf('The Emploi property can only contain items of type \CfcalSasieSDK\Entity\Emploi, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Emploi[] = $item;
        return $this;
    }
}
