Completed
Push — master ( 9b99bb...bc86a7 )
by Derek
02:38 queued 23s
created

System::allowOutput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Subreality\Dilmun\Nabu\LoggerHandler;
4
5
/**
6
 * Class System
7
 *
8
 * Simple log handler that writes to the system log using error_log.
9
 *
10
 * @package Subreality\Dilmun\Nabu\LoggerHandler
11
 *
12
 * @see error_log()
13
 */
14
class System implements HandlerInterface
0 ignored issues
show
Coding Style introduced by
The property $output_allowed is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
15
{
16
    private $output_allowed = true;
17
18 8
    public function __construct()
19
    {
20
        //No construction required!
21 8
    }
22
23
    /**
24
     * @return bool
25
     */
26 4
    public function initialize()
27
    {
28 4
        $initialize_status = error_log("Initializing System logger.");
29
30 4
        return $initialize_status;
31
    }
32
33
    /**
34
     * Writes to the configured PHP error logger.
35
     *
36
     * @see error_log()
37
     *
38
     * @param string $message   Message to be written to PHP's system log
39
     * @return bool             Returns the status from the error_log function
40
     */
41 9
    public function write($message)
42
    {
43 9
        if ($this->output_allowed) {
44 8
            $write_status = error_log($message);
45 8
        } else {
46 2
            $write_status = true;
47
        }
48
49 9
        return $write_status;
50
    }
51
52 2
    public function suppressOutput()
53
    {
54 2
        $this->output_allowed = false;
55 2
    }
56
57 1
    public function allowOutput()
58
    {
59 1
        $this->output_allowed = true;
60 1
    }
61
}
62