BrowserOutputter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 26
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A write() 0 5 3
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