Completed
Push — 1.0 ( 2b306a...ba3a86 )
by Alberto
01:57
created

core/kumbia/kumbia_facade.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * KumbiaPHP web & app Framework
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD license that is bundled
8
 * with this package in the file LICENSE.txt.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://wiki.kumbiaphp.com/Licencia
11
 * If you did not receive a copy of the license and are unable to
12
 * obtain it through the world-wide-web, please send an email
13
 * to [email protected] so we can send you a copy immediately.
14
 *
15
 * @category   Kumbia
16
 * @package    Core
17
 * @copyright  Copyright (c) 2005 - 2016 Kumbia Team (http://www.kumbiaphp.com)
18
 * @license    http://wiki.kumbiaphp.com/Licencia     New BSD License
19
 */
20
21
 /**
22
  * Clase principal para el manejo de excepciones
23
  *
24
  * @category   Kumbia
25
  * @package    Core
26
  */
27
 abstract class KumbiaFacade
28
 {
29
    protected static $providers = [];
30
31
32
    /**
33
     * Set the providers
34
     * @param  Array  $p key/value array with providers
35
     * @return void
36
     */
37
    public static function providers(Array $p){
38
        self::$providers = $p;
39
    }
40
41
    /**
42
     * Getter for the alias of the component
43
     */
44
    static function getAlias(){
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
45
        throw new RuntimeException('Not implement');
46
    }
47
48
49
    protected static function getInstance($name)
50
    {
51
        return  isset(self::$providers[$name])?self::$providers[$name]:null;
52
    }
53
54
    /**
55
     * Handle dynamic, static calls to the object.
56
     *
57
     * @param  string  $method
58
     * @param  array   $args
59
     * @return mixed
60
     *
61
     * @throws \RuntimeException
62
     */
63
    public static function __callStatic($method, $args)
64
    {
65
        $instance = self::getInstance(static::getAlias());
66
        if (! $instance) {
67
            throw new RuntimeException('A facade root has not been set.');
68
        }
69
70
        switch (count($args)) {
71
            case 0:
72
                return $instance->$method();
73
            case 1:
74
                return $instance->$method($args[0]);
75
            case 2:
76
                return $instance->$method($args[0], $args[1]);
77
            case 3:
78
                return $instance->$method($args[0], $args[1], $args[2]);
79
            case 4:
80
                return $instance->$method($args[0], $args[1], $args[2], $args[3]);
81
            default:
82
                return call_user_func_array([$instance, $method], $args);
83
        }
84
    }
85
86
 }
87