Total Complexity | 10 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class XHProfService |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var ProviderInterface |
||
17 | */ |
||
18 | protected $provider; |
||
19 | |||
20 | /** |
||
21 | * XHProfService constructor. |
||
22 | */ |
||
23 | public function __construct() |
||
24 | { |
||
25 | if (!extension_loaded(config('xhprof.extension_name', 'xhprof'))) { |
||
26 | return; |
||
27 | } |
||
28 | |||
29 | if (!config('xhprof.enabled', false)) { |
||
30 | return; |
||
31 | } |
||
32 | |||
33 | $freq = config('xhprof.freq', 0.01); |
||
34 | if ($freq >= (mt_rand() / mt_getrandmax())) { |
||
35 | switch (config('xhprof.provider', XHProfProvider::class)) { |
||
36 | case TidewaysProvider::class: |
||
37 | $this->provider = new TidewaysProvider(); |
||
38 | break; |
||
39 | default: |
||
40 | case XHProfProvider::class: |
||
41 | $this->provider = new XHProfProvider(); |
||
42 | break; |
||
43 | } |
||
44 | } |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return void |
||
49 | */ |
||
50 | public function enable(): void |
||
54 | } |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @return void |
||
59 | */ |
||
60 | public function disable(): void |
||
68 |