PhpXmlRpc_LoggerAwareTestCase::debug()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
include_once __DIR__ . '/../lib/xmlrpc.inc';
4
include_once __DIR__ . '/../lib/xmlrpcs.inc';
5
6
include_once __DIR__ . '/parse_args.php';
7
8
include_once __DIR__ . '/PolyfillTestCase.php';
9
10
use PHPUnit\Runner\BaseTestRunner;
11
12
abstract class PhpXmlRpc_LoggerAwareTestCase extends PhpXmlRpc_PolyfillTestCase
13
{
14
    protected $args = array();
15
16
    protected $buffer = '';
17
18
    /**
19
     * Hide debug messages and errors unless we either are in debug mode or the test fails.
20
     * @return void
21
     */
22
    protected function set_up()
23
    {
24
        $this->args = argParser::getArgs();
25
26
        if ($this->args['DEBUG'] == 0) {
27
            $this->debugBuffer = '';
0 ignored issues
show
Bug Best Practice introduced by
The property debugBuffer does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
28
            $this->errorBuffer = '';
0 ignored issues
show
Bug Best Practice introduced by
The property errorBuffer does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29
            \PhpXmlRpc\PhpXmlRpc::setLogger($this);
30
        }
31
    }
32
33
    protected function tear_down()
34
    {
35
        if ($this->args['DEBUG'] > 0) {
36
            return;
37
        }
38
39
        // reset the logger to the default
40
        \PhpXmlRpc\PhpXmlRpc::setLogger(\PhpXmlRpc\Helper\Logger::instance());
41
42
        $status = $this->getStatus();
43
        if ($status == BaseTestRunner::STATUS_ERROR
44
            || $status == BaseTestRunner::STATUS_FAILURE) {
45
            echo $this->buffer;
46
        }
47
    }
48
49
    // logger API implementation
50
51
    public function debug($message, $context = array())
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

51
    public function debug($message, /** @scrutinizer ignore-unused */ $context = array())

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

Loading history...
52
    {
53
        $this->buffer .= $message . "\n";
54
    }
55
56
    public function error($message, $context = array())
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

56
    public function error($message, /** @scrutinizer ignore-unused */ $context = array())

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

Loading history...
57
    {
58
        $this->buffer .= $message . "\n";
59
    }
60
61
    public function warning($message, $context = array())
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

61
    public function warning($message, /** @scrutinizer ignore-unused */ $context = array())

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

Loading history...
62
    {
63
        $this->buffer .= $message . "\n";
64
    }
65
}
66