-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgateway.php
More file actions
60 lines (54 loc) · 1.71 KB
/
gateway.php
File metadata and controls
60 lines (54 loc) · 1.71 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* gateway to common methods and properties
* requirements: PHP 5.3+
* common class including:
* common properties setup
* _get/_set methods
* custom methods/properties
*
* @package System
* @author Vallo Reima
* @copyright 2013
* @license BSD
*/
class ¤ {
private static $cmi; /* common instance */
private static $sep; /* path separator */
public static $_; /* workarea */
/**
* link to common data
* @param string $cln common class name
* @param string $sep path separator
*/
public static function _Init($cln = 'Common', $sep = '.') {
self::$cmi = new $cln(self::$_); /* instantiate the common class */
self::$sep = $sep; /* save property path separator */
}
/**
* access a method
* @param object $func method name
* @param array $args arguments list
* @return mixed
*/
public static function __callStatic($func, $args) {
return call_user_func_array(array(self::$cmi, $func), $args);
}
/**
* get/set a property value
* @param arguments -- 1st - path string
* 2nd - value (set only)
* @return mixed get/set value
*/
public static function _() {
$path = trim(func_get_arg(0), self::$sep); /* remove leading/trailing separators */
$pth = explode(self::$sep, $path); /* split the path */
if (func_num_args() > 1) {
$value = func_get_arg(1); /* value to set */
self::$cmi->_set($pth, $value); /* set a value */
} else {
$value = self::$cmi->_get($pth); /* get a value */
}
return $value;
}
}