-
Notifications
You must be signed in to change notification settings - Fork 1
/
Facade.php
56 lines (48 loc) · 1.12 KB
/
Facade.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
<?php
namespace Inflect;
/**
* This is a helper class that allows the usag of the Inflect\Inflect trought
* static calls
*
* @example
* // Calling Inflect::plurarize as if it was static
* Inflect\Facade::pluralize('pão')
*
* @package Inflect
*/
class Facade
{
static $inflector;
/**
* Returns an instance of Inflect\Inflect
*
* @return Inflect
*/
protected static function getInflector()
{
if (!self::$inflector) {
self::$inflector = new Inflect;
}
return self::$inflector;
}
/**
* Handle dynamic, static calls to the actual inflector instance
*
* @param string $method
* @param array $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
$instance = self::getInflector();
switch (count($args))
{
case 0:
return $instance->$method();
case 1:
return $instance->$method($args[0]);
default:
return call_user_func_array(array($instance, $method), $args);
}
}
}