<?php

namespace patest\ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

/**
 * This class stands for ArrayOfScreenParts.SupportedCulture ArrayType
 * Meta information extracted from the WSDL
 * - nillable: true
 * - type: tns:ArrayOfScreenParts.SupportedCulture
 * @subpackage Arrays
 */
class ArrayOfScreenParts_SupportedCulture extends AbstractStructArrayBase
{
    /**
     * The ScreenParts_SupportedCulture
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var \patest\StructType\ScreenParts_SupportedCulture[]
     */
    public $ScreenParts_SupportedCulture;
    /**
     * Constructor method for ArrayOfScreenParts.SupportedCulture
     * @uses ArrayOfScreenParts_SupportedCulture::setScreenParts_SupportedCulture()
     * @param \patest\StructType\ScreenParts_SupportedCulture[] $screenParts_SupportedCulture
     */
    public function __construct(array $screenParts_SupportedCulture = array())
    {
        $this
            ->setScreenParts_SupportedCulture($screenParts_SupportedCulture);
    }
    /**
     * Get ScreenParts_SupportedCulture 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 \patest\StructType\ScreenParts_SupportedCulture[]|null
     */
    public function getScreenParts_SupportedCulture()
    {
        return isset($this->{'ScreenParts.SupportedCulture'}) ? $this->{'ScreenParts.SupportedCulture'} : null;
    }
    /**
     * This method is responsible for validating the values passed to the setScreenParts_SupportedCulture method
     * This method is willingly generated in order to preserve the one-line inline validation within the setScreenParts_SupportedCulture method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateScreenParts_SupportedCultureForArrayConstraintsFromSetScreenParts_SupportedCulture(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $arrayOfScreenParts_SupportedCultureScreenParts_SupportedCultureItem) {
            // validation for constraint: itemType
            if (!$arrayOfScreenParts_SupportedCultureScreenParts_SupportedCultureItem instanceof \patest\StructType\ScreenParts_SupportedCulture) {
                $invalidValues[] = is_object($arrayOfScreenParts_SupportedCultureScreenParts_SupportedCultureItem) ? get_class($arrayOfScreenParts_SupportedCultureScreenParts_SupportedCultureItem) : sprintf('%s(%s)', gettype($arrayOfScreenParts_SupportedCultureScreenParts_SupportedCultureItem), var_export($arrayOfScreenParts_SupportedCultureScreenParts_SupportedCultureItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The ScreenParts_SupportedCulture property can only contain items of type \patest\StructType\ScreenParts_SupportedCulture, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set ScreenParts_SupportedCulture 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 \patest\StructType\ScreenParts_SupportedCulture[] $screenParts_SupportedCulture
     * @return \patest\ArrayType\ArrayOfScreenParts_SupportedCulture
     */
    public function setScreenParts_SupportedCulture(array $screenParts_SupportedCulture = array())
    {
        // validation for constraint: array
        if ('' !== ($screenParts_SupportedCultureArrayErrorMessage = self::validateScreenParts_SupportedCultureForArrayConstraintsFromSetScreenParts_SupportedCulture($screenParts_SupportedCulture))) {
            throw new \InvalidArgumentException($screenParts_SupportedCultureArrayErrorMessage, __LINE__);
        }
        if (is_null($screenParts_SupportedCulture) || (is_array($screenParts_SupportedCulture) && empty($screenParts_SupportedCulture))) {
            unset($this->ScreenParts_SupportedCulture, $this->{'ScreenParts.SupportedCulture'});
        } else {
            $this->ScreenParts_SupportedCulture = $this->{'ScreenParts.SupportedCulture'} = $screenParts_SupportedCulture;
        }
        return $this;
    }
    /**
     * Add item to ScreenParts_SupportedCulture value
     * @throws \InvalidArgumentException
     * @param \patest\StructType\ScreenParts_SupportedCulture $item
     * @return \patest\ArrayType\ArrayOfScreenParts_SupportedCulture
     */
    public function addToScreenParts_SupportedCulture(\patest\StructType\ScreenParts_SupportedCulture $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \patest\StructType\ScreenParts_SupportedCulture) {
            throw new \InvalidArgumentException(sprintf('The ScreenParts_SupportedCulture property can only contain items of type \patest\StructType\ScreenParts_SupportedCulture, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->ScreenParts_SupportedCulture[] = $this->{'ScreenParts.SupportedCulture'}[] = $item;
        return $this;
    }
    /**
     * Returns the current element
     * @see AbstractStructArrayBase::current()
     * @return \patest\StructType\ScreenParts_SupportedCulture|null
     */
    public function current()
    {
        return parent::current();
    }
    /**
     * Returns the indexed element
     * @see AbstractStructArrayBase::item()
     * @param int $index
     * @return \patest\StructType\ScreenParts_SupportedCulture|null
     */
    public function item($index)
    {
        return parent::item($index);
    }
    /**
     * Returns the first element
     * @see AbstractStructArrayBase::first()
     * @return \patest\StructType\ScreenParts_SupportedCulture|null
     */
    public function first()
    {
        return parent::first();
    }
    /**
     * Returns the last element
     * @see AbstractStructArrayBase::last()
     * @return \patest\StructType\ScreenParts_SupportedCulture|null
     */
    public function last()
    {
        return parent::last();
    }
    /**
     * Returns the element at the offset
     * @see AbstractStructArrayBase::offsetGet()
     * @param int $offset
     * @return \patest\StructType\ScreenParts_SupportedCulture|null
     */
    public function offsetGet($offset)
    {
        return parent::offsetGet($offset);
    }
    /**
     * Returns the attribute name
     * @see AbstractStructArrayBase::getAttributeName()
     * @return string ScreenParts.SupportedCulture
     */
    public function getAttributeName()
    {
        return 'ScreenParts.SupportedCulture';
    }
}
