Runtime::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Scabbia2 Helpers Component
4
 * https://github.com/eserozvataf/scabbia2
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @link        https://github.com/eserozvataf/scabbia2-helpers for the canonical source repository
10
 * @copyright   2010-2016 Eser Ozvataf. (http://eser.ozvataf.com/)
11
 * @license     http://www.apache.org/licenses/LICENSE-2.0 - Apache License, Version 2.0
12
 */
13
14
namespace Scabbia\Helpers;
15
16
/**
17
 * A bunch of utility methods for runtime hacks
18
 *
19
 * @package     Scabbia\Helpers
20
 * @author      Eser Ozvataf <[email protected]>
21
 * @since       2.0.0
22
 *
23
 * @scabbia-compile
24
 */
25
class Runtime
26
{
27
    /**
28
     * Default variables for runtime hacks
29
     *
30
     * @type array $defaults array of default variables
31
     */
32
    public static $defaults = [
33
    ];
34
35
36
    /**
37
     * Constructor to prevent new instances of Runtime class
38
     *
39
     * @return Runtime
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
40
     */
41
    final private function __construct()
42
    {
43
    }
44
45
    /**
46
     * Clone method to prevent duplication of Runtime class
47
     *
48
     * @return Runtime
49
     */
50
    final private function __clone()
51
    {
52
    }
53
54
    /**
55
     * Unserialization method to prevent restoration of Runtime class
56
     *
57
     * @return Runtime
58
     */
59
    final private function __wakeup()
60
    {
61
    }
62
63
    /**
64
     * Sets the default variables
65
     *
66
     * @param array $uDefaults variables to be set
67
     *
68
     * @return void
69
     */
70
    public static function setDefaults($uDefaults)
71
    {
72
        self::$defaults = $uDefaults + self::$defaults;
73
    }
74
75
    /**
76
     * Allows on-the-fly construction of classes
77
     *
78
     * @param mixed    $uCallback  callback
79
     *
80
     * @return mixed   callback
81
     */
82
    public static function callbacks($uCallback)
83
    {
84
        if (is_string($uCallback) && ($tPos = strrpos($uCallback, "@")) !== false) {
85
            $tClassName = substr($uCallback, 0, $tPos);
86
            $uCallback = [new $tClassName (), substr($uCallback, $tPos + 1)];
87
        }
88
89
        return $uCallback;
90
    }
91
}
92