1: <?php
2:
3: namespace Mypos\IPC;
4:
5: /**
6: * Library classes loader
7: */
8: class Loader{
9:
10: /**
11: * Find and include required class file
12: * @param string $class_name
13: * @return boolean
14: */
15: static public function loader($class_name){
16:
17: if(preg_match('/^' . str_replace('\\', '\\\\', __NAMESPACE__) . '\\\/', $class_name)){
18: $filePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . str_replace(array(__NAMESPACE__ . '\\', '\\'), array('', DIRECTORY_SEPARATOR), $class_name) . '.php';
19: if(is_file($filePath) && is_readable($filePath)){
20: require_once $filePath;
21: return true;
22: }
23: }
24: }
25:
26: }
27:
28: spl_autoload_register('\Mypos\IPC\Loader::loader');
29: