1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Commander project. |
4
|
|
|
* |
5
|
|
|
* @author Daniel Schröder <[email protected]> |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace GravityMedia\Commander; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Commander config class. |
12
|
|
|
* |
13
|
|
|
* @package GravityMedia\Commander |
14
|
|
|
*/ |
15
|
|
|
class Config |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* The default database file path. |
19
|
|
|
* |
20
|
|
|
* @const string |
21
|
|
|
*/ |
22
|
|
|
const DEFAULT_DATABASE_FILE_PATH = 'commander.sqlite'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The default timeout for process execution. |
26
|
|
|
* |
27
|
|
|
* @const string |
28
|
|
|
*/ |
29
|
|
|
const DEFAULT_PROCESS_TIMEOUT = 60; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The database file path. |
33
|
|
|
* |
34
|
|
|
* @var string|null |
35
|
|
|
*/ |
36
|
|
|
private $databaseFilePath; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* The cache directory. |
40
|
|
|
* |
41
|
|
|
* @var string|null |
42
|
|
|
*/ |
43
|
|
|
private $cacheDirectory; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* The log file path. |
47
|
|
|
* |
48
|
|
|
* @var string|null |
49
|
|
|
*/ |
50
|
|
|
private $logFilePath; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* The process timeout. |
54
|
|
|
* |
55
|
|
|
* @var int|null |
56
|
|
|
*/ |
57
|
|
|
private $processTimeout; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Get database file path. |
61
|
|
|
* |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
4 |
|
public function getDatabaseFilePath() |
65
|
|
|
{ |
66
|
4 |
|
if (null === $this->databaseFilePath) { |
67
|
2 |
|
return static::DEFAULT_DATABASE_FILE_PATH; |
68
|
|
|
} |
69
|
|
|
|
70
|
2 |
|
return $this->databaseFilePath; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Set database file path. |
75
|
|
|
* |
76
|
|
|
* @param string $databaseFilePath |
77
|
|
|
* |
78
|
|
|
* @return $this |
79
|
|
|
*/ |
80
|
2 |
|
public function setDatabaseFilePath($databaseFilePath) |
81
|
|
|
{ |
82
|
2 |
|
$this->databaseFilePath = $databaseFilePath; |
83
|
|
|
|
84
|
2 |
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Get cache directory. |
89
|
|
|
* |
90
|
|
|
* @return string|null |
91
|
|
|
*/ |
92
|
4 |
|
public function getCacheDirectory() |
93
|
|
|
{ |
94
|
4 |
|
return $this->cacheDirectory; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Set cache directory. |
99
|
|
|
* |
100
|
|
|
* @param string $cacheDirectory |
101
|
|
|
* |
102
|
|
|
* @return $this |
103
|
|
|
*/ |
104
|
2 |
|
public function setCacheDirectory($cacheDirectory) |
105
|
|
|
{ |
106
|
2 |
|
$this->cacheDirectory = $cacheDirectory; |
107
|
|
|
|
108
|
2 |
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Get log file path. |
113
|
|
|
* |
114
|
|
|
* @return string|null |
115
|
|
|
*/ |
116
|
4 |
|
public function getLogFilePath() |
117
|
|
|
{ |
118
|
4 |
|
return $this->logFilePath; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Set log file path. |
123
|
|
|
* |
124
|
|
|
* @param string $logFilePath |
125
|
|
|
* |
126
|
|
|
* @return $this |
127
|
|
|
*/ |
128
|
2 |
|
public function setLogFilePath($logFilePath) |
129
|
|
|
{ |
130
|
2 |
|
$this->logFilePath = $logFilePath; |
131
|
|
|
|
132
|
2 |
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Get process timeout. |
137
|
|
|
* |
138
|
|
|
* @return int |
139
|
|
|
*/ |
140
|
4 |
|
public function getProcessTimeout() |
141
|
|
|
{ |
142
|
4 |
|
if (null === $this->processTimeout) { |
143
|
2 |
|
return static::DEFAULT_PROCESS_TIMEOUT; |
144
|
|
|
} |
145
|
|
|
|
146
|
2 |
|
return $this->processTimeout; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Set process timeout. |
151
|
|
|
* |
152
|
|
|
* @param int $processTimeout |
153
|
|
|
* |
154
|
|
|
* @return $this |
155
|
|
|
*/ |
156
|
2 |
|
public function setProcessTimeout($processTimeout) |
157
|
|
|
{ |
158
|
2 |
|
$this->processTimeout = $processTimeout; |
159
|
|
|
|
160
|
2 |
|
return $this; |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
|