Completed
Push — hal-link ( 2c1f46...2273cc )
by Akihito
06:18 queued 04:53
created

ProdLogger::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource;
6
7
use function error_log;
8
use function in_array;
9
use function sprintf;
10
11
final class ProdLogger implements LoggerInterface
12
{
13
    public function __invoke(ResourceObject $ro) : void
14
    {
15
        $method = $ro->uri->method;
16
        $unsafeMethod = ['put', 'post', 'delete'];
17
        if (! in_array($method, $unsafeMethod, true)) {
18
            return;
19
        }
20
        $msg = sprintf('%s %s %s', $ro->code, $ro->uri->method, (string) $ro->uri);
21
        error_log($msg);
22
    }
23
}
24