<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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