<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Default_PO_Issue_Email_WWS_Widget_DataType StructType
 * Meta information extracted from the WSDL
 * - documentation: If Delete is set to true, Replace All must be set to false in Default PO Issue Email WWS Widget Data. | A wrapper element that contains data for Default PO Issue Email.
 * @subpackage Structs
 */
class Default_PO_Issue_Email_WWS_Widget_DataType extends AbstractStructBase
{
    /**
     * The Default_PO_Issue_Email_Data
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * @var \StructType\Default_PO_Issue_Email_WWS_DataType[]
     */
    public $Default_PO_Issue_Email_Data;
    /**
     * The Replace_All
     * Meta information extracted from the WSDL
     * - documentation: Replace All boolean to replace (True) or update (False) Default PO Issue Email information for a Supplier.
     * @var bool
     */
    public $Replace_All;
    /**
     * Constructor method for Default_PO_Issue_Email_WWS_Widget_DataType
     * @uses Default_PO_Issue_Email_WWS_Widget_DataType::setDefault_PO_Issue_Email_Data()
     * @uses Default_PO_Issue_Email_WWS_Widget_DataType::setReplace_All()
     * @param \StructType\Default_PO_Issue_Email_WWS_DataType[] $default_PO_Issue_Email_Data
     * @param bool $replace_All
     */
    public function __construct(array $default_PO_Issue_Email_Data = array(), $replace_All = null)
    {
        $this
            ->setDefault_PO_Issue_Email_Data($default_PO_Issue_Email_Data)
            ->setReplace_All($replace_All);
    }
    /**
     * Get Default_PO_Issue_Email_Data value
     * @return \StructType\Default_PO_Issue_Email_WWS_DataType[]|null
     */
    public function getDefault_PO_Issue_Email_Data()
    {
        return $this->Default_PO_Issue_Email_Data;
    }
    /**
     * This method is responsible for validating the values passed to the setDefault_PO_Issue_Email_Data method
     * This method is willingly generated in order to preserve the one-line inline validation within the setDefault_PO_Issue_Email_Data method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateDefault_PO_Issue_Email_DataForArrayConstraintsFromSetDefault_PO_Issue_Email_Data(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $default_PO_Issue_Email_WWS_Widget_DataTypeDefault_PO_Issue_Email_DataItem) {
            // validation for constraint: itemType
            if (!$default_PO_Issue_Email_WWS_Widget_DataTypeDefault_PO_Issue_Email_DataItem instanceof \StructType\Default_PO_Issue_Email_WWS_DataType) {
                $invalidValues[] = is_object($default_PO_Issue_Email_WWS_Widget_DataTypeDefault_PO_Issue_Email_DataItem) ? get_class($default_PO_Issue_Email_WWS_Widget_DataTypeDefault_PO_Issue_Email_DataItem) : sprintf('%s(%s)', gettype($default_PO_Issue_Email_WWS_Widget_DataTypeDefault_PO_Issue_Email_DataItem), var_export($default_PO_Issue_Email_WWS_Widget_DataTypeDefault_PO_Issue_Email_DataItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Default_PO_Issue_Email_Data property can only contain items of type \StructType\Default_PO_Issue_Email_WWS_DataType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Default_PO_Issue_Email_Data value
     * @throws \InvalidArgumentException
     * @param \StructType\Default_PO_Issue_Email_WWS_DataType[] $default_PO_Issue_Email_Data
     * @return \StructType\Default_PO_Issue_Email_WWS_Widget_DataType
     */
    public function setDefault_PO_Issue_Email_Data(array $default_PO_Issue_Email_Data = array())
    {
        // validation for constraint: array
        if ('' !== ($default_PO_Issue_Email_DataArrayErrorMessage = self::validateDefault_PO_Issue_Email_DataForArrayConstraintsFromSetDefault_PO_Issue_Email_Data($default_PO_Issue_Email_Data))) {
            throw new \InvalidArgumentException($default_PO_Issue_Email_DataArrayErrorMessage, __LINE__);
        }
        $this->Default_PO_Issue_Email_Data = $default_PO_Issue_Email_Data;
        return $this;
    }
    /**
     * Add item to Default_PO_Issue_Email_Data value
     * @throws \InvalidArgumentException
     * @param \StructType\Default_PO_Issue_Email_WWS_DataType $item
     * @return \StructType\Default_PO_Issue_Email_WWS_Widget_DataType
     */
    public function addToDefault_PO_Issue_Email_Data(\StructType\Default_PO_Issue_Email_WWS_DataType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Default_PO_Issue_Email_WWS_DataType) {
            throw new \InvalidArgumentException(sprintf('The Default_PO_Issue_Email_Data property can only contain items of type \StructType\Default_PO_Issue_Email_WWS_DataType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Default_PO_Issue_Email_Data[] = $item;
        return $this;
    }
    /**
     * Get Replace_All value
     * @return bool|null
     */
    public function getReplace_All()
    {
        return $this->Replace_All;
    }
    /**
     * Set Replace_All value
     * @param bool $replace_All
     * @return \StructType\Default_PO_Issue_Email_WWS_Widget_DataType
     */
    public function setReplace_All($replace_All = null)
    {
        // validation for constraint: boolean
        if (!is_null($replace_All) && !is_bool($replace_All)) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($replace_All, true), gettype($replace_All)), __LINE__);
        }
        $this->Replace_All = $replace_All;
        return $this;
    }
}
