1: <?php
2: namespace Contrib\Bundle\CoverallsV1Bundle\Config;
3:
4: /**
5: * Coveralls API configuration.
6: *
7: * @author Kitamura Satoshi <with.no.parachute@gmail.com>
8: */
9: class Configuration
10: {
11: // same as ruby lib
12:
13: /**
14: * repo_token.
15: *
16: * @var string
17: */
18: protected $repoToken;
19:
20: /**
21: * service_name.
22: *
23: * @var string
24: */
25: protected $serviceName;
26:
27: // only for php lib
28:
29: /**
30: * Absolute path to src directory to include coverage report.
31: *
32: * @var string
33: */
34: protected $srcDir;
35:
36: /**
37: * Absolute paths to clover.xml.
38: *
39: * @var array
40: */
41: protected $cloverXmlPaths = array();
42:
43: /**
44: * Absolute path to output json_file.
45: *
46: * @var string
47: */
48: protected $jsonPath;
49:
50: // from command option
51:
52: /**
53: * Whether to send json_file to jobs API.
54: *
55: * @var boolean
56: */
57: protected $dryRun = true;
58:
59: /**
60: * Whether to exclude source files that have no executable statements.
61: *
62: * @var boolean
63: */
64: protected $excludeNoStatements = false;
65:
66: /**
67: * Whether to show log.
68: *
69: * @var boolean
70: */
71: protected $verbose = false;
72:
73: /**
74: * Runtime environment name.
75: *
76: * @var string
77: */
78: protected $env = 'prod';
79:
80: // accessor
81:
82: /**
83: * Set repository token.
84: *
85: * @param string $repoToken
86: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
87: */
88: public function setRepoToken($repoToken)
89: {
90: $this->repoToken = $repoToken;
91:
92: return $this;
93: }
94:
95: /**
96: * Return whether repository token is configured.
97: *
98: * @return boolean
99: */
100: public function hasRepoToken()
101: {
102: return isset($this->repoToken);
103: }
104:
105: /**
106: * Return repository token.
107: *
108: * @return string|NULL
109: */
110: public function getRepoToken()
111: {
112: return $this->repoToken;
113: }
114:
115: /**
116: * Set service name.
117: *
118: * @param string $serviceName
119: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
120: */
121: public function setServiceName($serviceName)
122: {
123: $this->serviceName = $serviceName;
124:
125: return $this;
126: }
127:
128: /**
129: * Return whether the service name is configured.
130: *
131: * @return boolean
132: */
133: public function hasServiceName()
134: {
135: return isset($this->serviceName);
136: }
137:
138: /**
139: * Return service name.
140: *
141: * @return string|NULL
142: */
143: public function getServiceName()
144: {
145: return $this->serviceName;
146: }
147:
148: /**
149: * Set absolute path to src directory to include coverage report.
150: *
151: * @param string $srcDir
152: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
153: */
154: public function setSrcDir($srcDir)
155: {
156: $this->srcDir = $srcDir;
157:
158: return $this;
159: }
160:
161: /**
162: * Return absolute path to src directory to include coverage report.
163: *
164: * @return string
165: */
166: public function getSrcDir()
167: {
168: return $this->srcDir;
169: }
170:
171: /**
172: * Set absolute paths to clover.xml.
173: *
174: * @param string $cloverXmlPaths
175: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
176: */
177: public function setCloverXmlPaths(array $cloverXmlPaths)
178: {
179: $this->cloverXmlPaths = $cloverXmlPaths;
180:
181: return $this;
182: }
183:
184: /**
185: * Add absolute path to clover.xml.
186: *
187: * @param string $cloverXmlPath
188: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
189: */
190: public function addCloverXmlPath($cloverXmlPath)
191: {
192: $this->cloverXmlPaths[] = $cloverXmlPath;
193:
194: return $this;
195: }
196:
197: /**
198: * Return absolute path to clover.xml.
199: *
200: * @return string
201: */
202: public function getCloverXmlPaths()
203: {
204: return $this->cloverXmlPaths;
205: }
206:
207: /**
208: * Set absolute path to output json_file.
209: *
210: * @param string $jsonPath
211: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
212: */
213: public function setJsonPath($jsonPath)
214: {
215: $this->jsonPath = $jsonPath;
216:
217: return $this;
218: }
219:
220: /**
221: * Return absolute path to output json_file.
222: *
223: * @return string
224: */
225: public function getJsonPath()
226: {
227: return $this->jsonPath;
228: }
229:
230: /**
231: * Set whether to send json_file to jobs API.
232: *
233: * @param boolean $dryRun
234: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
235: */
236: public function setDryRun($dryRun)
237: {
238: $this->dryRun = $dryRun;
239:
240: return $this;
241: }
242:
243: /**
244: * Return whether to send json_file to jobs API.
245: *
246: * @return boolean
247: */
248: public function isDryRun()
249: {
250: return $this->dryRun;
251: }
252:
253: /**
254: * Set whether to exclude source files that have no executable statements.
255: *
256: * @param boolean $excludeNoStatements
257: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
258: */
259: public function setExcludeNoStatements($excludeNoStatements)
260: {
261: $this->excludeNoStatements = $excludeNoStatements;
262:
263: return $this;
264: }
265:
266: /**
267: * Set whether to exclude source files that have no executable statements unless false.
268: *
269: * @param boolean $excludeNoStatements
270: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
271: */
272: public function setExcludeNoStatementsUnlessFalse($excludeNoStatements)
273: {
274: if ($excludeNoStatements) {
275: $this->excludeNoStatements = true;
276: }
277:
278: return $this;
279: }
280:
281: /**
282: * Return whether to exclude source files that have no executable statements.
283: *
284: * @return boolean
285: */
286: public function isExcludeNoStatements()
287: {
288: return $this->excludeNoStatements;
289: }
290:
291: /**
292: * Set whether to show log.
293: *
294: * @param boolean $verbose
295: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
296: */
297: public function setVerbose($verbose)
298: {
299: $this->verbose = $verbose;
300:
301: return $this;
302: }
303:
304: /**
305: * Return whether to show log.
306: *
307: * @return boolean
308: */
309: public function isVerbose()
310: {
311: return $this->verbose;
312: }
313:
314: /**
315: * Set runtime environment name.
316: *
317: * @param string $env Runtime environment name.
318: * @return \Contrib\Bundle\CoverallsV1Bundle\Config\Configuration
319: */
320: public function setEnv($env)
321: {
322: $this->env = $env;
323:
324: return $this;
325: }
326:
327: /**
328: * Return runtime environment name.
329: *
330: * @return string
331: */
332: public function getEnv()
333: {
334: return $this->env;
335: }
336:
337: /**
338: * Return whether the runtime environment is test.
339: *
340: * @return boolean
341: */
342: public function isTestEnv()
343: {
344: return $this->env === 'test';
345: }
346:
347: /**
348: * Return whether the runtime environment is dev.
349: *
350: * @return boolean
351: */
352: public function isDevEnv()
353: {
354: return $this->env === 'dev';
355: }
356:
357: /**
358: * Return whether the runtime environment is prod.
359: *
360: * @return boolean
361: */
362: public function isProdEnv()
363: {
364: return $this->env === 'prod';
365: }
366: }
367: