<?php
use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for getProfilListResponse StructType
 * @subpackage Structs
 */
class GetProfilListResponse extends AbstractStructBase
{
    /**
     * The profil
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 1
     * @var ProfilType[]
     */
    public $profil;
    /**
     * Constructor method for getProfilListResponse
     * @uses GetProfilListResponse::setProfil()
     * @param ProfilType[] $profil
     */
    public function __construct(array $profil = array())
    {
        $this
            ->setProfil($profil);
    }
    /**
     * Get profil value
     * @return ProfilType[]
     */
    public function getProfil()
    {
        return $this->profil;
    }
    /**
     * This method is responsible for validating the values passed to the setProfil method
     * This method is willingly generated in order to preserve the one-line inline validation within the setProfil method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateProfilForArrayConstraintsFromSetProfil(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $getProfilListResponseProfilItem) {
            // validation for constraint: itemType
            if (!$getProfilListResponseProfilItem instanceof ProfilType) {
                $invalidValues[] = is_object($getProfilListResponseProfilItem) ? get_class($getProfilListResponseProfilItem) : sprintf('%s(%s)', gettype($getProfilListResponseProfilItem), var_export($getProfilListResponseProfilItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The profil property can only contain items of type ProfilType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set profil value
     * @throws \InvalidArgumentException
     * @param ProfilType[] $profil
     * @return GetProfilListResponse
     */
    public function setProfil(array $profil = array())
    {
        // validation for constraint: array
        if ('' !== ($profilArrayErrorMessage = self::validateProfilForArrayConstraintsFromSetProfil($profil))) {
            throw new \InvalidArgumentException($profilArrayErrorMessage, __LINE__);
        }
        $this->profil = $profil;
        return $this;
    }
    /**
     * Add item to profil value
     * @throws \InvalidArgumentException
     * @param ProfilType $item
     * @return GetProfilListResponse
     */
    public function addToProfil(ProfilType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof ProfilType) {
            throw new \InvalidArgumentException(sprintf('The profil property can only contain items of type ProfilType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->profil[] = $item;
        return $this;
    }
}
