<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for PaycheckJournalCompanyTaxList StructType
 * @subpackage Structs
 */
class PaycheckJournalCompanyTaxList extends AbstractStructBase
{
    /**
     * The paycheckJournalCompanyTax
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\PaycheckJournalCompanyTax[]
     */
    public $paycheckJournalCompanyTax;
    /**
     * The replaceAll
     * Meta information extracted from the WSDL
     * - default: true
     * @var bool
     */
    public $replaceAll;
    /**
     * Constructor method for PaycheckJournalCompanyTaxList
     * @uses PaycheckJournalCompanyTaxList::setPaycheckJournalCompanyTax()
     * @uses PaycheckJournalCompanyTaxList::setReplaceAll()
     * @param \StructType\PaycheckJournalCompanyTax[] $paycheckJournalCompanyTax
     * @param bool $replaceAll
     */
    public function __construct(array $paycheckJournalCompanyTax = array(), $replaceAll = true)
    {
        $this
            ->setPaycheckJournalCompanyTax($paycheckJournalCompanyTax)
            ->setReplaceAll($replaceAll);
    }
    /**
     * Get paycheckJournalCompanyTax value
     * @return \StructType\PaycheckJournalCompanyTax[]|null
     */
    public function getPaycheckJournalCompanyTax()
    {
        return $this->paycheckJournalCompanyTax;
    }
    /**
     * This method is responsible for validating the values passed to the setPaycheckJournalCompanyTax method
     * This method is willingly generated in order to preserve the one-line inline validation within the setPaycheckJournalCompanyTax method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validatePaycheckJournalCompanyTaxForArrayConstraintsFromSetPaycheckJournalCompanyTax(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $paycheckJournalCompanyTaxListPaycheckJournalCompanyTaxItem) {
            // validation for constraint: itemType
            if (!$paycheckJournalCompanyTaxListPaycheckJournalCompanyTaxItem instanceof \StructType\PaycheckJournalCompanyTax) {
                $invalidValues[] = is_object($paycheckJournalCompanyTaxListPaycheckJournalCompanyTaxItem) ? get_class($paycheckJournalCompanyTaxListPaycheckJournalCompanyTaxItem) : sprintf('%s(%s)', gettype($paycheckJournalCompanyTaxListPaycheckJournalCompanyTaxItem), var_export($paycheckJournalCompanyTaxListPaycheckJournalCompanyTaxItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The paycheckJournalCompanyTax property can only contain items of type \StructType\PaycheckJournalCompanyTax, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set paycheckJournalCompanyTax value
     * @throws \InvalidArgumentException
     * @param \StructType\PaycheckJournalCompanyTax[] $paycheckJournalCompanyTax
     * @return \StructType\PaycheckJournalCompanyTaxList
     */
    public function setPaycheckJournalCompanyTax(array $paycheckJournalCompanyTax = array())
    {
        // validation for constraint: array
        if ('' !== ($paycheckJournalCompanyTaxArrayErrorMessage = self::validatePaycheckJournalCompanyTaxForArrayConstraintsFromSetPaycheckJournalCompanyTax($paycheckJournalCompanyTax))) {
            throw new \InvalidArgumentException($paycheckJournalCompanyTaxArrayErrorMessage, __LINE__);
        }
        $this->paycheckJournalCompanyTax = $paycheckJournalCompanyTax;
        return $this;
    }
    /**
     * Add item to paycheckJournalCompanyTax value
     * @throws \InvalidArgumentException
     * @param \StructType\PaycheckJournalCompanyTax $item
     * @return \StructType\PaycheckJournalCompanyTaxList
     */
    public function addToPaycheckJournalCompanyTax(\StructType\PaycheckJournalCompanyTax $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\PaycheckJournalCompanyTax) {
            throw new \InvalidArgumentException(sprintf('The paycheckJournalCompanyTax property can only contain items of type \StructType\PaycheckJournalCompanyTax, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->paycheckJournalCompanyTax[] = $item;
        return $this;
    }
    /**
     * Get replaceAll value
     * @return bool|null
     */
    public function getReplaceAll()
    {
        return $this->replaceAll;
    }
    /**
     * Set replaceAll value
     * @param bool $replaceAll
     * @return \StructType\PaycheckJournalCompanyTaxList
     */
    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;
    }
}
