scratch – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
115 | office | 1 | <?php |
2 | |||
3 | /* |
||
4 | * This file is part of the Monolog package. |
||
5 | * |
||
6 | * (c) Jordi Boggiano <j.boggiano@seld.be> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Monolog\Formatter; |
||
13 | |||
14 | /** |
||
15 | * Formats data into an associative array of scalar values. |
||
16 | * Objects and arrays will be JSON encoded. |
||
17 | * |
||
18 | * @author Andrew Lawson <adlawson@gmail.com> |
||
19 | */ |
||
20 | class ScalarFormatter extends NormalizerFormatter |
||
21 | { |
||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | public function format(array $record) |
||
26 | { |
||
27 | foreach ($record as $key => $value) { |
||
28 | $record[$key] = $this->normalizeValue($value); |
||
29 | } |
||
30 | |||
31 | return $record; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param mixed $value |
||
36 | * @return mixed |
||
37 | */ |
||
38 | protected function normalizeValue($value) |
||
39 | { |
||
40 | $normalized = $this->normalize($value); |
||
41 | |||
42 | if (is_array($normalized) || is_object($normalized)) { |
||
43 | return $this->toJson($normalized, true); |
||
44 | } |
||
45 | |||
46 | return $normalized; |
||
47 | } |
||
48 | } |