<?php

namespace CfcalSasieSDK\Entity;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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