File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,23 @@ public function __construct()
9393 parent ::__construct ();
9494 }
9595
96+ /**
97+ * Use for Calling Non-Existent Functions, handling Getters and Setters
98+ * @param function set/get{name} = private/protected property that needs to be accessed
99+ */
100+ public function __call ($ function , $ args )
101+ {
102+ $ prefix = substr ($ function , 0 , 3 );
103+ $ property = strtolower (substr ($ function , 3 , strlen ($ function )));
104+ if ($ prefix == 'set ' ) {
105+ $ this ->$ property = $ args [0 ];
106+ } elseif ($ prefix == 'get ' ) {
107+ return $ this ->$ property ;
108+ } else {
109+ throw new Exception ("$ function does not exist " );
110+ }
111+ }
112+
96113 /**
97114 * Get host and port from an "host:port" notation.
98115 * Returns array of host and port. If port is omitted, returns $default
You can’t perform that action at this time.
0 commit comments