pinba_emulator.php ➔ get_pinba_logger()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Mikhail Dolgov <[email protected]>
4
 * @date   04.03.2016 17:54
5
 */
6
7
/**
8
 * @return \Psr\Log\LoggerInterface
9
 * @throws Exception
10
 */
11
function get_pinba_logger()
12
{
13
    /**
14
     * @var $app \Silex\Application
15
     */
16
    global $app;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
17
    static $logger = null;
18
    if(is_null($logger)) {
19
        $logger = $app['pinba_logger'];
20
    }
21
    return $logger;
22
}
23
24
function pinba_script_name_set ($name){
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
    get_pinba_logger()->debug(__FUNCTION__, func_get_args());
26
}
27
function pinba_timer_start ($tags){
0 ignored issues
show
Unused Code introduced by
The parameter $tags is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    get_pinba_logger()->debug(__FUNCTION__, func_get_args());
29
    return rand(100,999);
30
}
31
function pinba_timer_stop ($tags){
0 ignored issues
show
Unused Code introduced by
The parameter $tags is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    get_pinba_logger()->debug(__FUNCTION__, func_get_args());
33
}
34
function pinba_timer_add ($tags, $time){
0 ignored issues
show
Unused Code introduced by
The parameter $tags is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $time is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
    get_pinba_logger()->debug(__FUNCTION__, func_get_args());
36
}
37
function pinba_get_info (){
38
    get_pinba_logger()->debug(__FUNCTION__);
39
    return array(
40
        'hostname'    => 'emulate hostname',
41
        "server_name" => 'emulate server name',
42
    );
43
 }