KumbiaFacade   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 56
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A providers() 0 4 1
A getAlias() 0 4 1
A getInstance() 0 4 2
A __callStatic() 0 18 5
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.
9
 *
10
 * @category   Kumbia
11
 *
12
 * @copyright  Copyright (c) 2005 - 2019 KumbiaPHP Team (http://www.kumbiaphp.com)
13
 * @license    https://github.com/KumbiaPHP/KumbiaPHP/blob/master/LICENSE   New BSD License
14
 */
15
16
 /**
17
  * Clase principal para el manejo de excepciones.
18
  *
19
  * @category   Kumbia
20
  */
21
 abstract class KumbiaFacade
22
 {
23
     protected static $providers = [];
24
25
     /**
26
      * Set the providers.
27
      *
28
      * @param array $p key/value array with providers
29
      */
30
     public static function providers(array $p)
31
     {
32
         self::$providers = $p;
33
     }
34
35
     /**
36
      * Getter for the alias of the component.
37
      */
38
     protected static function getAlias()
39
     {
40
         throw new KumbiaException('Not implement');
41
     }
42
43
     protected static function getInstance($name)
44
     {
45
         return  isset(self::$providers[$name]) ? self::$providers[$name] : null;
46
     }
47
48
     /**
49
      * Handle dynamic, static calls to the object.
50
      *
51
      * @param string $method
52
      * @param array  $args
53
      *
54
      * @return mixed
55
      *
56
      * @throws \KumbiaException
57
      */
58
     public static function __callStatic($method, $args)
59
     {
60
         $instance = self::getInstance(static::getAlias());
61
         if (!$instance) {
62
             throw new KumbiaException('A facade root has not been set.');
63
         }
64
65
         switch (count($args)) {
66
            case 0:
67
                return $instance->$method();
68
            case 1:
69
                return $instance->$method($args[0]);
70
            case 2:
71
                return $instance->$method($args[0], $args[1]);
72
            default:
73
                return call_user_func_array([$instance, $method], $args);
74
        }
75
     }
76
 }
77