Completed
Pull Request — master (#4)
by
unknown
09:38 queued 20s
created

src/Phiber/ORM/Logger/PhiberLogger.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * Copyright (c) 2017. Este código foi feito por @marciioluucas, sob licença MIT
5
 */
6
namespace Phiber\ORM\Logger;
7
8
use Phiber\Util\Internationalization;
9
use Phiber\Util\JsonReader;
10
11
/**
12
 * Classe responsável por criar o log do Phiber
13
 */
14
class PhiberLogger
15
{
16
    /**
17
     * Cria o log.
18
     * 
19
     * @param        $languageReference
20
     * @param string $level
21
     * @param string $objectName
22
     * @param null   $execTime
23
     */
24
    public static function create($languageReference, $level = 'info', $objectName = '', $execTime = null)
25
    {
26
        if (JsonReader::read(BASE_DIR.'/phiber_config.json')->phiber->log == 1 ? true : false) {
0 ignored issues
show
The call to JsonReader::read() has too many arguments starting with BASE_DIR . '/phiber_config.json'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
27
            $date = date('Y-m-d H:i:s');
28
            switch ($level) {
29 View Code Duplication
                case 'info':
0 ignored issues
show
This code seems to be duplicated across 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...
30
                    $levelStr = strtoupper(new Internationalization("log_info"));
31
                    $msg = "\033[0;35m PHIBER LOG -> [$date] [$levelStr]: (" .
32
                    new Internationalization("reference") .
33
                    "=> \"$objectName\") " . new Internationalization($languageReference) .
34
                    " - ";
35
                    if($execTime != null){
36
                        $msg .=  "em " . $execTime . ".";
37
                    }
38
                    echo $msg . "\e[0m \n";
39
                    break;
40
41 View Code Duplication
                case 'warning':
0 ignored issues
show
This code seems to be duplicated across 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...
42
                    $levelStr = strtoupper(new Internationalization("log_warning"));
43
                    $msg = "\033[1;33m PHIBER LOG -> [$date] [$levelStr]: (" .
44
                        new Internationalization("reference") .
45
                        "=> \"$objectName\") " . new Internationalization($languageReference) .
46
                        " - ";
47
                    if($execTime != null){
48
                        $msg .=  "em " . $execTime . ".";
49
                    }
50
                    echo $msg . "\e[0m \n";
51
                    break;
52
53 View Code Duplication
                case 'error':
0 ignored issues
show
This code seems to be duplicated across 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...
54
                    $levelStr = strtoupper(new Internationalization("log_error"));
55
                    $msg = "\033[0;31m PHIBER LOG -> [$date] [$levelStr]: (" .
56
                        new Internationalization("reference") .
57
                        "=> \"$objectName\") " . new Internationalization($languageReference) .
58
                        " - ";
59
                    if($execTime != null){
60
                        $msg .=  "em " . $execTime . ".";
61
                    }
62
                    echo $msg . "\e[0m \n";
63
                    break;
64
            }
65
        }
66
    }
67
}
68