1212
1313trait 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}
0 commit comments