<?php

namespace CfcalSasieSDK\Entity;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Emprunteurs Entity
 * Meta information extracted from the WSDL
 * - nillable: true
 * - type: tns:Emprunteurs
 * @subpackage Structs
 */
class Emprunteurs extends AbstractStructBase
{
    /**
     * The Emprunteur
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var \CfcalSasieSDK\Entity\Emprunteur[]
     */
    public $Emprunteur;
    /**
     * Constructor method for Emprunteurs
     * @uses Emprunteurs::setEmprunteur()
     * @param \CfcalSasieSDK\Entity\Emprunteur[] $emprunteur
     */
    public function __construct(array $emprunteur = array())
    {
        $this
            ->setEmprunteur($emprunteur);
    }
    /**
     * Get Emprunteur 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\Emprunteur[]|null
     */
    public function getEmprunteur()
    {
        return isset($this->Emprunteur) ? $this->Emprunteur : null;
    }
    /**
     * This method is responsible for validating the values passed to the setEmprunteur method
     * This method is willingly generated in order to preserve the one-line inline validation within the setEmprunteur method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateEmprunteurForArrayConstraintsFromSetEmprunteur(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $emprunteursEmprunteurItem) {
            // validation for constraint: itemType
            if (!$emprunteursEmprunteurItem instanceof \CfcalSasieSDK\Entity\Emprunteur) {
                $invalidValues[] = is_object($emprunteursEmprunteurItem) ? get_class($emprunteursEmprunteurItem) : sprintf('%s(%s)', gettype($emprunteursEmprunteurItem), var_export($emprunteursEmprunteurItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Emprunteur property can only contain items of type \CfcalSasieSDK\Entity\Emprunteur, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Emprunteur 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\Emprunteur[] $emprunteur
     * @return \CfcalSasieSDK\Entity\Emprunteurs
     */
    public function setEmprunteur(array $emprunteur = array())
    {
        // validation for constraint: array
        if ('' !== ($emprunteurArrayErrorMessage = self::validateEmprunteurForArrayConstraintsFromSetEmprunteur($emprunteur))) {
            throw new \InvalidArgumentException($emprunteurArrayErrorMessage, __LINE__);
        }
        if (is_null($emprunteur) || (is_array($emprunteur) && empty($emprunteur))) {
            unset($this->Emprunteur);
        } else {
            $this->Emprunteur = $emprunteur;
        }
        return $this;
    }
    /**
     * Add item to Emprunteur value
     * @throws \InvalidArgumentException
     * @param \CfcalSasieSDK\Entity\Emprunteur $item
     * @return \CfcalSasieSDK\Entity\Emprunteurs
     */
    public function addToEmprunteur(\CfcalSasieSDK\Entity\Emprunteur $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \CfcalSasieSDK\Entity\Emprunteur) {
            throw new \InvalidArgumentException(sprintf('The Emprunteur property can only contain items of type \CfcalSasieSDK\Entity\Emprunteur, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Emprunteur[] = $item;
        return $this;
    }
}
