1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Lechimp\Dicto\Report; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Configuration for a concrete report. |
7
|
|
|
*/ |
8
|
|
|
class Config { |
9
|
|
|
/** |
10
|
|
|
* @var string |
11
|
|
|
*/ |
12
|
|
|
protected $path; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var string|null |
16
|
|
|
*/ |
17
|
|
|
protected $name; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $class_name; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $target; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string|null |
31
|
|
|
*/ |
32
|
|
|
protected $source_path; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var array |
36
|
|
|
*/ |
37
|
|
|
protected $config; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param string $path to where the config is |
41
|
|
|
* @param string $class_name to be used for report creation |
42
|
|
|
* @param string $target path to the file to be created |
43
|
|
|
* @param array $config for the report class |
44
|
|
|
* @param string|null $name to target the report in commands etc. |
45
|
|
|
* @param string|null $source_path of the report class if it needs to be loaded |
46
|
|
|
* explicitely |
47
|
|
|
*/ |
48
|
|
|
public function __construct($path, $class_name, $target, array $config, $name = null, $source_path = null) { |
49
|
|
|
assert('is_string($path)'); |
50
|
|
|
assert('is_string($class_name)'); |
51
|
|
|
assert('is_string($target)'); |
52
|
|
|
assert('is_string($name) || is_null($name)'); |
53
|
|
|
assert('is_string($source_path)'); |
54
|
|
|
$this->path = $path; |
55
|
|
|
$this->class_name = $class_name; |
56
|
|
|
$this->target = $target; |
57
|
|
|
$this->config = $config; |
58
|
|
|
$this->name = $name; |
59
|
|
|
$this->source_path = $source_path; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function name() { |
66
|
|
|
return $this->name; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function path() { |
73
|
|
|
return $this->path; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
public function class_name() { |
80
|
|
|
return $this->class_name; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return string |
85
|
|
|
*/ |
86
|
|
|
public function target() { |
87
|
|
|
return $this->target; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param string |
92
|
|
|
* @return self |
93
|
|
|
*/ |
94
|
|
|
public function with_target($target) { |
95
|
|
|
assert('is_string($target)'); |
96
|
|
|
$clone = clone $this; |
97
|
|
|
$clone->target = $target; |
98
|
|
|
return $clone; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return array |
103
|
|
|
*/ |
104
|
|
|
public function config() { |
105
|
|
|
return $this->config; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
public function source_path() { |
112
|
|
|
return $this->source_path; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|