Passed
Push — master ( cf47da...53c71b )
by James
21:48 queued 09:49
created

AuditProcessor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 2
1
<?php
2
3
/**
4
 * AuditProcessor.php
5
 * Copyright (c) 2019 [email protected]
6
 *
7
 * This file is part of Firefly III.
8
 *
9
 * Firefly III is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation, either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * Firefly III is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
declare(strict_types=1);
24
25
namespace FireflyIII\Support\Logging;
26
27
/**
28
 * Class AuditProcessor
29
 */
30
class AuditProcessor
31
{
32
    /**
33
     * @param array $record
34
     *
35
     * @return array
36
     */
37
    public function __invoke(array $record): array
38
    {
39
        $record['extra']['path'] = request()->method() . ':' . request()->url();
40
41
        $record['extra']['IP'] = app('request')->ip();
42
        if (auth()->check()) {
43
            $record['extra']['user'] = auth()->user()->email;
44
        }
45
46
47
        return $record;
48
    }
49
}
50