<?php

namespace CfcalSasieSDK\Entity;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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