-
Notifications
You must be signed in to change notification settings - Fork 0
/
PropertyTypes.php
46 lines (38 loc) · 945 Bytes
/
PropertyTypes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Skype API Wrapper
*
* PHP versions 5.4
*
* @author П$ix <[email protected]>
*/
namespace SkypeWrapper;
class PropertyTypes {
// TODO: support enum, datetime, etc...
const string = "string";
const int = "int";
const bool = "bool";
private static function string($strValue)
{
return $strValue;
}
private static function int($strValue)
{
return intval($strValue);
}
private static function bool($strValue)
{
return $strValue == "TRUE" ? true : false;
}
public static function force($type, $value) {
// util, суть массива пока не осознал
if (is_array($type)) {
if ($type[0] == self::int || $type[0] == self::string)
return preg_split('/,\s+/', $value);
}
if(method_exists(__CLASS__, $type))
return self::$type($value);
throw new \Exception(sprintf("unsupported propety type [%s] [%s]", var_export($type, true), var_export($value, true)));
}
}
?>