Completed
Push — feature/0.7.0 ( 79c386...7f3169 )
by Ryuichi
03:02
created

ConsoleOutputter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 29
loc 29
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A write() 7 7 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace WebStream\Log\Outputter;
3
4
/**
5
 * ConsoleOutputter
6
 * @author Ryuichi Tanaka
7
 * @since 2016/01/26
8
 * @version 0.7
9
 */
10 View Code Duplication
class ConsoleOutputter implements IOutputter
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /**
13
     * https://github.com/php/php-src/tree/master/sapi
14
     * PHP7以前のものは対応しない
15
     * @var SAPIリスト
16
     */
17
    private $sapis = [
18
        'apache2handler' => 'http',
19
        'cgi'            => 'http',
20
        'cli'            => 'console',
21
        'fpm'            => 'http',
22
        'embed'          => 'unsupported',
23
        'litespeed'      => 'unsupported',
24
        'phpdbg'         => 'unsupported',
25
        'tests'          => 'unsupported'
26
    ];
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function write($text)
32
    {
33
        $sapi = php_sapi_name();
34
        if (array_key_exists($sapi, $this->sapis) && $this->sapis[$sapi] === 'console') {
35
            echo $text . PHP_EOL;
36
        }
37
    }
38
}
39