<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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