Logger::info()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 7
rs 10
ccs 0
cts 5
cp 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of forecast.it.fill project.
7
 * (c) Patrick Jaja <[email protected]>
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace ForecastAutomation\Log\Business;
13
14
use Psr\Log\LoggerInterface;
15
use Throwable;
16
17
class Logger
18
{
19
    /**
20
     * @param LoggerInterface $logger
21
     */
22
    public function __construct(private LoggerInterface $logger)
23
    {
24
    }
25
26
    public function info(string $message, array $context): void
27
    {
28
        $this->logger->info(
29
            $message,
30
            [
31
                'message' => $message,
32
                'context' => $context,
33
            ]
34
        );
35
    }
36
37
    public function error(string $message, Throwable $e = null): void
38
    {
39
        $this->logger->error(
40
            $message,
41
            [
42
                'message' => $message,
43
                'throwable' => $e,
44
            ]
45
        );
46
    }
47
}
48