Completed
Push — develop ( 2c8389...1b732a )
by Mikaël
35:25
created

EwsArrayOfTransitionsType::addToTransition()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 9
rs 9.6666
cc 3
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Ews\StructType;
4
5
use \WsdlToPhp\PackageBase\AbstractStructBase;
6
7
/**
8
 * This class stands for ArrayOfTransitionsType StructType
9
 * @package Ews
10
 * @subpackage Structs
11
 * @author WsdlToPhp <[email protected]>
12
 */
13
class EwsArrayOfTransitionsType extends AbstractStructBase
14
{
15
    /**
16
     * The Transition
17
     * Meta informations extracted from the WSDL
18
     * - maxOccurs: unbounded
19
     * - ref: t:Transition
20
     * @var \Ews\StructType\EwsTransitionType[]
21
     */
22
    public $Transition;
23
    /**
24
     * The Id
25
     * @var string
26
     */
27
    public $Id;
28
    /**
29
     * Constructor method for ArrayOfTransitionsType
30
     * @uses EwsArrayOfTransitionsType::setTransition()
31
     * @uses EwsArrayOfTransitionsType::setId()
32
     * @param \Ews\StructType\EwsTransitionType[] $transition
33
     * @param string $id
34
     */
35
    public function __construct(array $transition = array(), $id = null)
36
    {
37
        $this
38
            ->setTransition($transition)
39
            ->setId($id);
40
    }
41
    /**
42
     * Get Transition value
43
     * @return \Ews\StructType\EwsTransitionType[]|null
44
     */
45
    public function getTransition()
46
    {
47
        return $this->Transition;
48
    }
49
    /**
50
     * Set Transition value
51
     * @throws \InvalidArgumentException
52
     * @param \Ews\StructType\EwsTransitionType[] $transition
53
     * @return \Ews\StructType\EwsArrayOfTransitionsType
54
     */
55
    public function setTransition(array $transition = array())
56
    {
57
        foreach ($transition as $arrayOfTransitionsTypeTransitionItem) {
58
            // validation for constraint: itemType
59
            if (!$arrayOfTransitionsTypeTransitionItem instanceof \Ews\StructType\EwsTransitionType) {
60
                throw new \InvalidArgumentException(sprintf('The Transition property can only contain items of \Ews\StructType\EwsTransitionType, "%s" given', is_object($arrayOfTransitionsTypeTransitionItem) ? get_class($arrayOfTransitionsTypeTransitionItem) : gettype($arrayOfTransitionsTypeTransitionItem)), __LINE__);
61
            }
62
        }
63
        $this->Transition = $transition;
64
        return $this;
65
    }
66
    /**
67
     * Add item to Transition value
68
     * @throws \InvalidArgumentException
69
     * @param \Ews\StructType\EwsTransitionType $item
70
     * @return \Ews\StructType\EwsArrayOfTransitionsType
71
     */
72
    public function addToTransition(\Ews\StructType\EwsTransitionType $item)
73
    {
74
        // validation for constraint: itemType
75
        if (!$item instanceof \Ews\StructType\EwsTransitionType) {
76
            throw new \InvalidArgumentException(sprintf('The Transition property can only contain items of \Ews\StructType\EwsTransitionType, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
77
        }
78
        $this->Transition[] = $item;
79
        return $this;
80
    }
81
    /**
82
     * Get Id value
83
     * @return string|null
84
     */
85
    public function getId()
86
    {
87
        return $this->Id;
88
    }
89
    /**
90
     * Set Id value
91
     * @param string $id
92
     * @return \Ews\StructType\EwsArrayOfTransitionsType
93
     */
94
    public function setId($id = null)
95
    {
96
        // validation for constraint: string
97
        if (!is_null($id) && !is_string($id)) {
98
            throw new \InvalidArgumentException(sprintf('Invalid value, please provide a string, "%s" given', gettype($id)), __LINE__);
99
        }
100
        $this->Id = $id;
101
        return $this;
102
    }
103
    /**
104
     * Method called when an object has been exported with var_export() functions
105
     * It allows to return an object instantiated with the values
106
     * @see AbstractStructBase::__set_state()
107
     * @uses AbstractStructBase::__set_state()
108
     * @param array $array the exported values
109
     * @return \Ews\StructType\EwsArrayOfTransitionsType
110
     */
111
    public static function __set_state(array $array)
112
    {
113
        return parent::__set_state($array);
114
    }
115
    /**
116
     * Method returning the class name
117
     * @return string __CLASS__
118
     */
119
    public function __toString()
120
    {
121
        return __CLASS__;
122
    }
123
}
124