-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_overload.php
More file actions
57 lines (45 loc) · 1.44 KB
/
_overload.php
File metadata and controls
57 lines (45 loc) · 1.44 KB
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
57
<?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/main/blob/master/LICENSE
*/
namespace Quid\Main;
use Quid\Base;
// _overload
// trait that allows a class to retrieve its overloaded version - higher up in the class hierarchy
trait _overload
{
// getOverloadKey
// retourne la clé utilisé pour le tableau overload
final public static function getOverloadKey():string
{
$return = static::className();
$prepend = static::getOverloadKeyPrepend();
if(!empty($prepend))
$return = Base\Fqcn::append($prepend,$return);
return $return;
}
// getOverloadKeyPrepend
// retourne le prepend de la clé à utiliser pour le tableau overload
public static function getOverloadKeyPrepend():?string
{
return null;
}
// classOverload
// retourne la classe à utiliser pour un overload
final public static function classOverload():string
{
return Autoload::getOverload(static::getOverloadKey(),static::class);
}
// newOverload
// retourne une nouvelle instance de la classe mais en utilisant le nom de classe overloader si existant
public static function newOverload(...$values):self
{
$class = static::classOverload();
$return = new $class(...$values);
return $return;
}
}
?>