<?php

namespace Pepitelabs\PWS\PickUpService;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for NotificationEmails PickUpService
 * Meta information extracted from the WSDL
 * - nillable: true
 * - type: tns:NotificationEmails
 * @subpackage Structs
 */
class NotificationEmails extends AbstractStructBase
{
    /**
     * The NotificationEmail
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var string[]
     */
    public $NotificationEmail;
    /**
     * Constructor method for NotificationEmails
     * @uses NotificationEmails::setNotificationEmail()
     * @param string[] $notificationEmail
     */
    public function __construct(array $notificationEmail = array())
    {
        $this
            ->setNotificationEmail($notificationEmail);
    }
    /**
     * Get NotificationEmail 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 string[]|null
     */
    public function getNotificationEmail()
    {
        return isset($this->NotificationEmail) ? $this->NotificationEmail : null;
    }
    /**
     * This method is responsible for validating the values passed to the setNotificationEmail method
     * This method is willingly generated in order to preserve the one-line inline validation within the setNotificationEmail method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateNotificationEmailForArrayConstraintsFromSetNotificationEmail(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $notificationEmailsNotificationEmailItem) {
            // validation for constraint: itemType
            if (!is_string($notificationEmailsNotificationEmailItem)) {
                $invalidValues[] = is_object($notificationEmailsNotificationEmailItem) ? get_class($notificationEmailsNotificationEmailItem) : sprintf('%s(%s)', gettype($notificationEmailsNotificationEmailItem), var_export($notificationEmailsNotificationEmailItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The NotificationEmail property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set NotificationEmail 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 string[] $notificationEmail
     * @return \Pepitelabs\PWS\PickUpService\NotificationEmails
     */
    public function setNotificationEmail(array $notificationEmail = array())
    {
        // validation for constraint: array
        if ('' !== ($notificationEmailArrayErrorMessage = self::validateNotificationEmailForArrayConstraintsFromSetNotificationEmail($notificationEmail))) {
            throw new \InvalidArgumentException($notificationEmailArrayErrorMessage, __LINE__);
        }
        if (is_null($notificationEmail) || (is_array($notificationEmail) && empty($notificationEmail))) {
            unset($this->NotificationEmail);
        } else {
            $this->NotificationEmail = $notificationEmail;
        }
        return $this;
    }
    /**
     * Add item to NotificationEmail value
     * @throws \InvalidArgumentException
     * @param string $item
     * @return \Pepitelabs\PWS\PickUpService\NotificationEmails
     */
    public function addToNotificationEmail($item)
    {
        // validation for constraint: itemType
        if (!is_string($item)) {
            throw new \InvalidArgumentException(sprintf('The NotificationEmail property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->NotificationEmail[] = $item;
        return $this;
    }
    /**
     * Method called when an object has been exported with var_export() functions
     * It allows to return an object instantiated with the values
     * @see AbstractStructBase::__set_state()
     * @uses AbstractStructBase::__set_state()
     * @param array $array the exported values
     * @return \Pepitelabs\PWS\PickUpService\NotificationEmails
     */
    public static function __set_state(array $array)
    {
        return parent::__set_state($array);
    }
    /**
     * Method returning the class name
     * @return string __CLASS__
     */
    public function __toString()
    {
        return __CLASS__;
    }
}
