BrowserOutputter::write()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
cc 3
nc 2
nop 1
crap 12
1
<?php
2
3
namespace WebStream\Log\Outputter;
4
5
/**
6
 * BrowserOutputter
7
 * @author Ryuichi Tanaka
8
 * @since 2016/01/26
9
 * @version 0.7
10
 */
11
class BrowserOutputter implements IOutputter
12
{
13
    /**
14
     * https://github.com/php/php-src/tree/master/sapi
15
     * PHP7以前のものは対応しない
16
     * @var array
17
     */
18
    private $sapis = [
19
        'apache2handler' => 'http',
20
        'cgi'            => 'http',
21
        'cli'            => 'console',
22
        'fpm'            => 'http',
23
        'embed'          => 'unsupported',
24
        'litespeed'      => 'unsupported',
25
        'phpdbg'         => 'unsupported',
26
        'tests'          => 'unsupported'
27
    ];
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function write(string $message)
33
    {
34
        $sapi = php_sapi_name();
35
        if (array_key_exists($sapi, $this->sapis) && $this->sapis[$sapi] === 'http') {
36
            echo $message . "<br>";
37
        }
38
    }
39
}
40