XHProfProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A enable() 0 3 1
A disable() 0 9 1
1
<?php
2
3
namespace Bavix\XHProf\Providers;
4
5
use XHProfRuns_Default;
0 ignored issues
show
Bug introduced by
The type XHProfRuns_Default was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use function xhprof_disable;
7
use function xhprof_enable;
8
9
class XHProfProvider implements ProviderInterface
10
{
11
12
    /**
13
     * @inheritDoc
14
     */
15
    public function enable()
16
    {
17
        xhprof_enable(config('xhprof.flags', 0));
18
    }
19
20
    /**
21
     * @inheritDoc
22
     */
23
    public function disable()
24
    {
25
        $data = xhprof_disable();
26
27
        $run_id = config('xhprof.run_id', null) ?? uniqid();
28
29
        file_put_contents(
30
                config('xhprof.output_dir', '/tmp') . '/' . $run_id . '.' . config('xhprof.name') . '.xhprof',
31
                serialize($data)
32
                );
33
    }
34
35
}
36