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

ProdLogger   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 2
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