<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for AccountingPeriodFiscalCalendarsList StructType
 * @subpackage Structs
 */
class AccountingPeriodFiscalCalendarsList extends AbstractStructBase
{
    /**
     * The accountingPeriodFiscalCalendars
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\AccountingPeriodFiscalCalendars[]
     */
    public $accountingPeriodFiscalCalendars;
    /**
     * The replaceAll
     * Meta information extracted from the WSDL
     * - default: true
     * @var bool
     */
    public $replaceAll;
    /**
     * Constructor method for AccountingPeriodFiscalCalendarsList
     * @uses AccountingPeriodFiscalCalendarsList::setAccountingPeriodFiscalCalendars()
     * @uses AccountingPeriodFiscalCalendarsList::setReplaceAll()
     * @param \StructType\AccountingPeriodFiscalCalendars[] $accountingPeriodFiscalCalendars
     * @param bool $replaceAll
     */
    public function __construct(array $accountingPeriodFiscalCalendars = array(), $replaceAll = true)
    {
        $this
            ->setAccountingPeriodFiscalCalendars($accountingPeriodFiscalCalendars)
            ->setReplaceAll($replaceAll);
    }
    /**
     * Get accountingPeriodFiscalCalendars value
     * @return \StructType\AccountingPeriodFiscalCalendars[]|null
     */
    public function getAccountingPeriodFiscalCalendars()
    {
        return $this->accountingPeriodFiscalCalendars;
    }
    /**
     * This method is responsible for validating the values passed to the setAccountingPeriodFiscalCalendars method
     * This method is willingly generated in order to preserve the one-line inline validation within the setAccountingPeriodFiscalCalendars method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateAccountingPeriodFiscalCalendarsForArrayConstraintsFromSetAccountingPeriodFiscalCalendars(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $accountingPeriodFiscalCalendarsListAccountingPeriodFiscalCalendarsItem) {
            // validation for constraint: itemType
            if (!$accountingPeriodFiscalCalendarsListAccountingPeriodFiscalCalendarsItem instanceof \StructType\AccountingPeriodFiscalCalendars) {
                $invalidValues[] = is_object($accountingPeriodFiscalCalendarsListAccountingPeriodFiscalCalendarsItem) ? get_class($accountingPeriodFiscalCalendarsListAccountingPeriodFiscalCalendarsItem) : sprintf('%s(%s)', gettype($accountingPeriodFiscalCalendarsListAccountingPeriodFiscalCalendarsItem), var_export($accountingPeriodFiscalCalendarsListAccountingPeriodFiscalCalendarsItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The accountingPeriodFiscalCalendars property can only contain items of type \StructType\AccountingPeriodFiscalCalendars, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set accountingPeriodFiscalCalendars value
     * @throws \InvalidArgumentException
     * @param \StructType\AccountingPeriodFiscalCalendars[] $accountingPeriodFiscalCalendars
     * @return \StructType\AccountingPeriodFiscalCalendarsList
     */
    public function setAccountingPeriodFiscalCalendars(array $accountingPeriodFiscalCalendars = array())
    {
        // validation for constraint: array
        if ('' !== ($accountingPeriodFiscalCalendarsArrayErrorMessage = self::validateAccountingPeriodFiscalCalendarsForArrayConstraintsFromSetAccountingPeriodFiscalCalendars($accountingPeriodFiscalCalendars))) {
            throw new \InvalidArgumentException($accountingPeriodFiscalCalendarsArrayErrorMessage, __LINE__);
        }
        $this->accountingPeriodFiscalCalendars = $accountingPeriodFiscalCalendars;
        return $this;
    }
    /**
     * Add item to accountingPeriodFiscalCalendars value
     * @throws \InvalidArgumentException
     * @param \StructType\AccountingPeriodFiscalCalendars $item
     * @return \StructType\AccountingPeriodFiscalCalendarsList
     */
    public function addToAccountingPeriodFiscalCalendars(\StructType\AccountingPeriodFiscalCalendars $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\AccountingPeriodFiscalCalendars) {
            throw new \InvalidArgumentException(sprintf('The accountingPeriodFiscalCalendars property can only contain items of type \StructType\AccountingPeriodFiscalCalendars, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->accountingPeriodFiscalCalendars[] = $item;
        return $this;
    }
    /**
     * Get replaceAll value
     * @return bool|null
     */
    public function getReplaceAll()
    {
        return $this->replaceAll;
    }
    /**
     * Set replaceAll value
     * @param bool $replaceAll
     * @return \StructType\AccountingPeriodFiscalCalendarsList
     */
    public function setReplaceAll($replaceAll = true)
    {
        // validation for constraint: boolean
        if (!is_null($replaceAll) && !is_bool($replaceAll)) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($replaceAll, true), gettype($replaceAll)), __LINE__);
        }
        $this->replaceAll = $replaceAll;
        return $this;
    }
}
