PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Satooshi/Bundle/CoverallsV1Bundle/Config/Configuration.php

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