PsrMessage::getMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace samdark\log;
4
5
/**
6
 * Data transfer object implementation for advanced PSR3 message and context handling
7
 *
8
 * @author Maksim Rodikov <[email protected]>
9
 * @package samdark\log
10
 */
11
final class PsrMessage
12
{
13
    /** @var string */
14
    private $message;
15
16
    /** @var array */
17
    private $context = [];
18
19
    public function __construct($message, $context = [])
20
    {
21
        $this->message = (string) $message;
22
        $this->context = is_array($context) ? $context : [$context];
23
    }
24
25
    /**
26
     * @return string
27
     */
28
    public function getMessage()
29
    {
30
        return $this->message;
31
    }
32
33
    /**
34
     * @return array
35
     */
36
    public function getContext()
37
    {
38
        return $this->context;
39
    }
40
41
    /**
42
     * PSR3 compatibility
43
     *
44
     * @return string
45
     */
46
    public function __toString()
47
    {
48
        return $this->getMessage();
49
    }
50
51
}