<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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