|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* (c) Jean-François Lépine <https://twitter.com/Halleck45> |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Hal\Application\Config; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Log configuration |
|
14
|
|
|
* |
|
15
|
|
|
* @author Jean-François Lépine <https://twitter.com/Halleck45> |
|
16
|
|
|
*/ |
|
17
|
|
|
class LoggingConfiguration |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* Datas |
|
21
|
|
|
* |
|
22
|
|
|
* @var array |
|
23
|
|
|
*/ |
|
24
|
|
|
private $datas; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Constructor |
|
28
|
|
|
* |
|
29
|
|
|
* @param array $datas |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct(array $datas = array()) { |
|
32
|
|
|
$this->datas = array_merge(array('violations'=> array(), 'report' => array(), 'chart' => array()), $datas); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Get target of report by format |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $format |
|
39
|
|
|
* @return string|null |
|
40
|
|
|
*/ |
|
41
|
|
|
public function getReport($format) { |
|
42
|
|
|
return isset($this->datas['report'], $this->datas['report'][$format]) |
|
43
|
|
|
? $this->datas['report'][$format] |
|
44
|
|
|
: null; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Get target of report by format |
|
49
|
|
|
* |
|
50
|
|
|
* @param string $format |
|
51
|
|
|
* @return string|null |
|
52
|
|
|
*/ |
|
53
|
|
|
public function getViolation($format) { |
|
54
|
|
|
return isset($this->datas['violations'], $this->datas['violations'][$format]) |
|
55
|
|
|
? $this->datas['violations'][$format] |
|
56
|
|
|
: null; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Get target of report by format |
|
61
|
|
|
* |
|
62
|
|
|
* @param string $format |
|
63
|
|
|
* @return string|null |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getChart($format) { |
|
66
|
|
|
return isset($this->datas['chart'], $this->datas['chart'][$format]) |
|
67
|
|
|
? $this->datas['chart'][$format] |
|
68
|
|
|
: null; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Set report |
|
73
|
|
|
* |
|
74
|
|
|
* @param string $format |
|
75
|
|
|
* @param $path |
|
76
|
|
|
* @return $this |
|
77
|
|
|
*/ |
|
78
|
|
|
public function setReport($format, $path) { |
|
79
|
|
|
$this->datas['report'][$format] = $path; |
|
80
|
|
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Set violation |
|
85
|
|
|
* |
|
86
|
|
|
* @param string $format |
|
87
|
|
|
* @param $path |
|
88
|
|
|
* @return $this |
|
89
|
|
|
*/ |
|
90
|
|
|
public function setViolation($format, $path) { |
|
91
|
|
|
$this->datas['violations'][$format] = $path; |
|
92
|
|
|
return $this; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Set report |
|
97
|
|
|
* |
|
98
|
|
|
* @param string $format |
|
99
|
|
|
* @param $path |
|
100
|
|
|
* @return $this |
|
101
|
|
|
*/ |
|
102
|
|
|
public function setChart($format, $path) { |
|
103
|
|
|
$this->datas['chart'][$format] = $path; |
|
104
|
|
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
} |