<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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