-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_config.php
50 lines (41 loc) · 1.28 KB
/
_config.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
<?php
declare(strict_types=1);
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <emondpph@gmail.com>
* License: https://github.com/quidphp/base/blob/master/LICENSE
*/
namespace Quid\Base;
// _config
// trait that grants static methods to get or set data within static config
trait _config
{
// getConfig
// permet d'obtenir une valeur de la config de la classe
final public static function getConfig($key)
{
return Arrs::get($key,static::$config);
}
// config
// retourne le tableau de config
// possibilité de faire un merge sur la valeur de retour
// par défaut, cette méthode écrit dans la variable statique (à l'inverse de option)
final public static function config(?array $value=null,bool $write=true):?array
{
$return = null;
$class = static::class;
if(property_exists($class,'config') && is_array(static::$config))
{
$return = static::$config;
if($value !== null)
{
$callable = static::getInitCallable();
$return = $callable($class,$return,$value);
if($write === true)
static::$config = $return;
}
}
return $return;
}
}
?>