ArrayFormatter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 3
Bugs 2 Features 0
Metric Value
wmc 3
eloc 10
c 3
b 2
f 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 15 3
1
<?php
2
namespace App\Monolog;
3
4
use Monolog\Formatter\NormalizerFormatter;
5
6
class ArrayFormatter extends NormalizerFormatter
7
{
8
	/**
9
	 * {@inheritdoc}
10
	 */
11
	public function format(array $record)
12
	{
13
		/** @var \DateTime $date */
14
		$date = $record['datetime'];
15
		$output = array(sprintf("%s %s", $record['level_name'], $date->format("d.m.Y H:i:s")));
16
        $output[] = $record['message'];
17
        if(!empty($record['context'])) {
18
            if(is_array($record['context'])) {
19
                $output[] = print_r($record['context'], true);
20
            } else {
21
                $output[] = $record['context'];
22
            }
23
        }
24
25
		return join("\r\n", $output) . "\r\n------------------------------------------------------------------------\r\n";
26
	}
27
}
28