Passed
Push — master ( 0d021b...39a3b8 )
by Melech
01:29
created

Logger   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A log() 0 16 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Valkyrja\Log\Logger\Abstract;
15
16
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Stringable;
18
use Valkyrja\Log\Enum\LogLevel;
19
use Valkyrja\Log\Logger\Contract\LoggerContract;
20
use Valkyrja\Log\Throwable\Exception\InvalidArgumentException;
21
22
abstract class Logger implements LoggerContract
23
{
24
    /**
25
     * @inheritDoc
26
     */
27
    #[Override]
28
    public function log($level, string|Stringable $message, array $context = []): void
29
    {
30
        if (! $level instanceof LogLevel) {
31
            throw new InvalidArgumentException('Invalid log level passed. Expecting instance of' . LogLevel::class);
32
        }
33
34
        match ($level) {
35
            LogLevel::ALERT     => $this->alert($message, $context),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->alert($message, $context) targeting Valkyrja\Log\Logger\Cont...LoggerContract::alert() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
36
            LogLevel::DEBUG     => $this->debug($message, $context),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->debug($message, $context) targeting Valkyrja\Log\Logger\Cont...LoggerContract::debug() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
37
            LogLevel::INFO      => $this->info($message, $context),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->info($message, $context) targeting Valkyrja\Log\Logger\Cont...\LoggerContract::info() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
38
            LogLevel::NOTICE    => $this->notice($message, $context),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->notice($message, $context) targeting Valkyrja\Log\Logger\Cont...oggerContract::notice() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
39
            LogLevel::WARNING   => $this->warning($message, $context),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->warning($message, $context) targeting Valkyrja\Log\Logger\Cont...ggerContract::warning() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
40
            LogLevel::ERROR     => $this->error($message, $context),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->error($message, $context) targeting Valkyrja\Log\Logger\Cont...LoggerContract::error() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
41
            LogLevel::CRITICAL  => $this->critical($message, $context),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->critical($message, $context) targeting Valkyrja\Log\Logger\Cont...gerContract::critical() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
42
            LogLevel::EMERGENCY => $this->emergency($message, $context),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->emergency($message, $context) targeting Valkyrja\Log\Logger\Cont...erContract::emergency() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
43
        };
44
    }
45
}
46