<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Project_Timesheet_Response_DataType StructType
 * Meta information extracted from the WSDL
 * - documentation: Project Timesheet Response Data
 * @subpackage Structs
 */
class Project_Timesheet_Response_DataType extends AbstractStructBase
{
    /**
     * The Project_Timesheet
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\Project_TimesheetType[]
     */
    public $Project_Timesheet;
    /**
     * Constructor method for Project_Timesheet_Response_DataType
     * @uses Project_Timesheet_Response_DataType::setProject_Timesheet()
     * @param \StructType\Project_TimesheetType[] $project_Timesheet
     */
    public function __construct(array $project_Timesheet = array())
    {
        $this
            ->setProject_Timesheet($project_Timesheet);
    }
    /**
     * Get Project_Timesheet value
     * @return \StructType\Project_TimesheetType[]|null
     */
    public function getProject_Timesheet()
    {
        return $this->Project_Timesheet;
    }
    /**
     * This method is responsible for validating the values passed to the setProject_Timesheet method
     * This method is willingly generated in order to preserve the one-line inline validation within the setProject_Timesheet method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateProject_TimesheetForArrayConstraintsFromSetProject_Timesheet(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $project_Timesheet_Response_DataTypeProject_TimesheetItem) {
            // validation for constraint: itemType
            if (!$project_Timesheet_Response_DataTypeProject_TimesheetItem instanceof \StructType\Project_TimesheetType) {
                $invalidValues[] = is_object($project_Timesheet_Response_DataTypeProject_TimesheetItem) ? get_class($project_Timesheet_Response_DataTypeProject_TimesheetItem) : sprintf('%s(%s)', gettype($project_Timesheet_Response_DataTypeProject_TimesheetItem), var_export($project_Timesheet_Response_DataTypeProject_TimesheetItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Project_Timesheet property can only contain items of type \StructType\Project_TimesheetType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Project_Timesheet value
     * @throws \InvalidArgumentException
     * @param \StructType\Project_TimesheetType[] $project_Timesheet
     * @return \StructType\Project_Timesheet_Response_DataType
     */
    public function setProject_Timesheet(array $project_Timesheet = array())
    {
        // validation for constraint: array
        if ('' !== ($project_TimesheetArrayErrorMessage = self::validateProject_TimesheetForArrayConstraintsFromSetProject_Timesheet($project_Timesheet))) {
            throw new \InvalidArgumentException($project_TimesheetArrayErrorMessage, __LINE__);
        }
        $this->Project_Timesheet = $project_Timesheet;
        return $this;
    }
    /**
     * Add item to Project_Timesheet value
     * @throws \InvalidArgumentException
     * @param \StructType\Project_TimesheetType $item
     * @return \StructType\Project_Timesheet_Response_DataType
     */
    public function addToProject_Timesheet(\StructType\Project_TimesheetType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Project_TimesheetType) {
            throw new \InvalidArgumentException(sprintf('The Project_Timesheet property can only contain items of type \StructType\Project_TimesheetType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Project_Timesheet[] = $item;
        return $this;
    }
}
