Passed
Pull Request — main (#74)
by mohsen
02:31
created

FileDriver::clean()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MohsenAbrishami\Stethoscope\LogRecord\Drivers;
4
5
use Illuminate\Support\Facades\Storage;
6
use MohsenAbrishami\Stethoscope\LogRecord\Contracts\LogRecordInterface;
7
use MohsenAbrishami\Stethoscope\Traits\MessageCreatorTrait;
8
9
class FileDriver implements LogRecordInterface
10
{
11
    use MessageCreatorTrait;
12
13
    public function record($resourceLogs)
14
    {
15
        $file = config('stethoscope.log_file_storage.path') . now()->format('Y-m-d');
16
17
        $this->storage = Storage::disk(config('stethoscope.log_file_storage.driver'));
0 ignored issues
show
Bug Best Practice introduced by
The property storage does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
18
19
        $log = '';
20
21
        foreach ($resourceLogs as $resource => $report) {
22
            $method = $resource . 'Message';
23
24
            if (method_exists($this, $method)) {
25
                $log .= $this->$method($report) . "\n";
26
            }
27
        }
28
29
        if ($log != '') {
30
            $log = $this->timeMessage() . "\n" . $log;
31
32
            if ($this->storage->exists($file))
33
                $log = $this->storage->get($file) . "\n \n" . $log;
34
35
            $this->storage->put($file, $log);
36
        }
37
    }
38
39
    public function clean()
40
    {
41
        //
42
    }
43
}
44