-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtension.php
94 lines (75 loc) · 2.48 KB
/
Extension.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
declare(strict_types=1);
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <[email protected]>
* License: https://github.com/quidphp/base/blob/master/LICENSE
*/
namespace Quid\Base;
// extension
// class which contains methods to deal with PHP extensions
final class Extension extends Root
{
// config
protected static array $config = [
'required'=>[ // extensions requises
'ctype','curl','date','fileinfo','gd','iconv','json','mbstring','pcre',
'PDO','pdo_mysql','openssl','session','SimpleXML','zip']
];
// is
// retourne vrai si une extension est chargé
final public static function is(string $name):bool
{
return is_string($name) && extension_loaded($name);
}
// hasOpCache
// retourne vrai si l'extension opcache est chargé
final public static function hasOpCache(bool $ini=false):bool
{
$return = self::is('Zend OPcache');
return ($return === true && $ini === true)? Ini::opcache():$return;
}
// hasXdebug
// retourne vrai si l'extension xdebug est chargé
final public static function hasXdebug(bool $ini=false):bool
{
$return = self::is('xdebug');
return ($return === true && $ini === true)? Ini::xdebug():$return;
}
// hasApcu
// retourne vrai si l'extension apcu est chargé
final public static function hasApcu(bool $ini=false):bool
{
$return = self::is('apcu');
return ($return === true && $ini === true)? Ini::apcu():$return;
}
// functions
// retourne les fonctions d'une extension
final public static function functions(string $name):array
{
return (self::is($name))? get_extension_funcs($name):[];
}
// important
// retourn un tableau avec les résultats des méthodes pour détecter opcache, xdebug et apcu
final public static function important(bool $ini=false):array
{
return [
'opcache'=>self::hasOpCache($ini),
'xdebug'=>self::hasXdebug($ini),
'apcu'=>self::hasApcu($ini)
];
}
// all
// retourne les extensions php
final public static function all():array
{
return get_loaded_extensions();
}
// requirement
// lance les tests de requirement
final public static function requirement():array
{
return Arr::accumulate([],self::$config['required'],fn($value) => !self::is($value)? $value:null);
}
}
?>