<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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