-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResolver.php
82 lines (75 loc) · 2.05 KB
/
Resolver.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace Cygnite\Proxy;
use Cygnite\DependencyInjection\Container;
use Cygnite\Foundation\Application;
use Cygnite\Helpers\Inflector;
if (!defined('CF_SYSTEM')) {
exit('External script access not allowed');
}
/**
* Class Resolver
*
* We will make use of Resolver to resolve all static calls.
*
* @package Cygnite\Proxy
*/
abstract class Resolver
{
/**
* @return Inflector
*/
private static function getInflection()
{
return new Inflector();
}
/**
* We will return proxy objects from container
*
* @return Container
*/
protected static function getContainer()
{
return new Container();
}
/**
* All static methods will get resolve by Proxy Resolver
*
* @param $method
* @param array $arguments
* @return mixed
*/
public static function __callStatic($method, $arguments = array())
{
$accessor = $inflection = $instance = null;
$accessor = static::getResolver();
$inflection = self::getInflection();
$accessor = $inflection->toNamespace($accessor);
$instance = new $accessor();
// calling the method directly is faster then call_user_func_array() !
switch (count($arguments))
{
case 0:
return $instance->$method();
case 1:
return $instance->$method($arguments[0]);
case 2:
return $instance->$method($arguments[0], $arguments[1]);
case 3:
return $instance->$method($arguments[0], $arguments[1], $arguments[2]);
case 4:
return $instance->$method($arguments[0], $arguments[1], $arguments[2], $arguments[3]);
default:
return call_user_func_array(array($instance, $method), $arguments);
}
}
/**
* Get the object instance for this Facade
*
* @since 1.2.1
*/
public static function getInstance()
{
// This Facade doesn't have instance support
return null;
}
}