Skip to content

Commit 4b6dc2d

Browse files
committed
Do the string -> DateTime casting inside the setter method. Remove the caster altogether and remove _typeMap
1 parent a304764 commit 4b6dc2d

336 files changed

Lines changed: 1898 additions & 2830 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/API/MagicMethodsTrait.php

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
trait MagicMethodsTrait
1414
{
15-
protected $_typeMap = [];
16-
1715
public function __call($name, $arguments)
1816
{
1917
$callTypeIndex = 3;
@@ -42,7 +40,7 @@ public function __set($name, $value)
4240
}
4341

4442
if ($this->methodExists("set" . ucfirst($name))) {
45-
$this->{"set" . ucfirst($name)}($this->castValueIfNeeded(lcfirst($name), $value));
43+
$this->{"set" . ucfirst($name)}($value);
4644
return;
4745
}
4846

@@ -72,7 +70,6 @@ public function get($name)
7270
public function set($name, $value)
7371
{
7472
$name = $this->getNameInCorrectCase($name);
75-
$value = $this->castValueIfNeeded($name, $value);
7673

7774
$this->$name = $value;
7875

@@ -82,7 +79,6 @@ public function set($name, $value)
8279
public function add($name, $value)
8380
{
8481
$name = $this->getNameInCorrectCase($name);
85-
$value = $this->castValueIfNeeded($name, $value);
8682

8783
if ($this->$name == null) {
8884
$this->$name = array();
@@ -105,20 +101,6 @@ public function is($name)
105101
return ((bool) $this->$name);
106102
}
107103

108-
public function cast($value, $type)
109-
{
110-
return Caster::cast($value, $type);
111-
}
112-
113-
public function castToExchange($value, $type)
114-
{
115-
if (Caster::castExists($type, 'ExchangeFormat')) {
116-
$value = Caster::cast($value, 'ExchangeFormat');
117-
}
118-
119-
return $value;
120-
}
121-
122104
protected function getValidNameInCorrectCase($names)
123105
{
124106
foreach ($names as $name) {
@@ -149,20 +131,4 @@ protected function getNameInCorrectCase($name)
149131

150132
return $name;
151133
}
152-
153-
/**
154-
* @param $name
155-
* @param $value
156-
* @return null
157-
*/
158-
protected function castValueIfNeeded($name, $value)
159-
{
160-
if (isset($this->_typeMap[$name])) {
161-
$value = $this->cast($value, $this->_typeMap[$name]);
162-
163-
return $value;
164-
}
165-
166-
return $value;
167-
}
168134
}

src/API/Message/AddDelegateType.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ class AddDelegateType extends BaseDelegateType
2828
*/
2929
public function addDelegateUsers(\garethp\ews\API\Type\DelegateUserType $value)
3030
{
31-
$value = $this->castValueIfNeeded("delegateUsers", $value);
32-
3331
if ($this->delegateUsers === null) {
34-
$this->delegateUsers = array();
32+
$this->delegateUsers = array();
3533
}
3634

3735
if (!is_array($this->delegateUsers)) {
@@ -62,7 +60,7 @@ public function setDelegateUsers(array|\garethp\ews\API\Type\DelegateUserType $v
6260
if (!is_array($value)) {
6361
$value = [$value];
6462
}
65-
$this->delegateUsers = $this->castValueIfNeeded("delegateUsers", $value);
63+
$this->delegateUsers = $value;
6664
return $this;
6765
}
6866

@@ -82,7 +80,7 @@ public function getDeliverMeetingRequests()
8280
*/
8381
public function setDeliverMeetingRequests($value)
8482
{
85-
$this->deliverMeetingRequests = $this->castValueIfNeeded("deliverMeetingRequests", $value);
83+
$this->deliverMeetingRequests = $value;
8684
return $this;
8785
}
8886
}

src/API/Message/ApplyConversationActionType.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ class ApplyConversationActionType extends BaseRequestType
2323
*/
2424
public function addConversationActions(\garethp\ews\API\Type\ConversationActionType $value)
2525
{
26-
$value = $this->castValueIfNeeded("conversationActions", $value);
27-
2826
if ($this->conversationActions === null) {
29-
$this->conversationActions = array();
27+
$this->conversationActions = array();
3028
}
3129

3230
if (!is_array($this->conversationActions)) {
@@ -57,7 +55,7 @@ public function setConversationActions(array|\garethp\ews\API\Type\ConversationA
5755
if (!is_array($value)) {
5856
$value = [$value];
5957
}
60-
$this->conversationActions = $this->castValueIfNeeded("conversationActions", $value);
58+
$this->conversationActions = $value;
6159
return $this;
6260
}
6361
}

0 commit comments

Comments
 (0)