Total Complexity | 7 |
Total Lines | 72 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
17 | class Syslog extends AbstractAdapter |
||
18 | { |
||
19 | /** |
||
20 | * Syslog ident. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $ident; |
||
25 | |||
26 | /** |
||
27 | * Option. |
||
28 | * |
||
29 | * @var int |
||
30 | */ |
||
31 | protected $option = LOG_PID; |
||
32 | |||
33 | /** |
||
34 | * Facility. |
||
35 | * |
||
36 | * @var int |
||
37 | */ |
||
38 | protected $facility = LOG_SYSLOG; |
||
39 | |||
40 | /** |
||
41 | * Set options. |
||
42 | * |
||
43 | * @return AdapterInterface |
||
44 | */ |
||
45 | public function setOptions(? Iterable $config = null): AdapterInterface |
||
46 | { |
||
47 | if (null === $config) { |
||
48 | return $this; |
||
49 | } |
||
50 | |||
51 | foreach ($config as $option => $value) { |
||
52 | switch ($option) { |
||
53 | case 'ident': |
||
54 | $this->ident = (string) $value; |
||
55 | unset($config[$option]); |
||
56 | |||
57 | break; |
||
58 | case 'option': |
||
59 | $this->option = (int) (string) $value; |
||
60 | unset($config[$option]); |
||
61 | |||
62 | break; |
||
63 | case 'facility': |
||
64 | $this->facility = (int) (string) $value; |
||
65 | unset($config[$option]); |
||
66 | |||
67 | break; |
||
68 | } |
||
69 | } |
||
70 | |||
71 | parent::setOptions($config); |
||
72 | |||
73 | openlog($this->ident, $this->option, $this->facility); |
||
74 | |||
75 | return $this; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Log. |
||
80 | * |
||
81 | * @param string $level |
||
82 | * @param string $message |
||
83 | * |
||
84 | * @return bool |
||
85 | */ |
||
86 | public function log(string $level, string $message): bool |
||
89 | } |
||
90 | } |
||
91 |