MemoryPackage.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Package;
  12. /**
  13. * A package with setters for all members to create it dynamically in memory
  14. *
  15. * @author Nils Adermann <naderman@naderman.de>
  16. */
  17. class MemoryPackage extends BasePackage
  18. {
  19. protected $type;
  20. protected $installationSource;
  21. protected $sourceType;
  22. protected $sourceUrl;
  23. protected $sourceReference;
  24. protected $distType;
  25. protected $distUrl;
  26. protected $distReference;
  27. protected $distSha1Checksum;
  28. protected $releaseType;
  29. protected $version;
  30. protected $license;
  31. protected $extra = array();
  32. protected $requires = array();
  33. protected $conflicts = array();
  34. protected $provides = array();
  35. protected $replaces = array();
  36. protected $recommends = array();
  37. protected $suggests = array();
  38. /**
  39. * Creates a new in memory package.
  40. *
  41. * @param string $name The package's name
  42. * @param string $version The package's version
  43. * @param string $releaseType The package's release type (beta/rc/stable/dev)
  44. */
  45. public function __construct($name, $version, $releaseType = 'stable')
  46. {
  47. parent::__construct($name);
  48. $this->releaseType = $releaseType;
  49. $this->version = $version;
  50. }
  51. /**
  52. * @param string $type
  53. */
  54. public function setType($type)
  55. {
  56. $this->type = $type;
  57. }
  58. /**
  59. * {@inheritDoc}
  60. */
  61. public function getType()
  62. {
  63. return $this->type ?: 'library';
  64. }
  65. /**
  66. * @param array $extra
  67. */
  68. public function setExtra(array $extra)
  69. {
  70. $this->extra = $extra;
  71. }
  72. /**
  73. * {@inheritDoc}
  74. */
  75. public function getExtra()
  76. {
  77. return $this->extra;
  78. }
  79. /**
  80. * {@inheritDoc}
  81. */
  82. public function setInstallationSource($type)
  83. {
  84. $this-> installationSource = $type;
  85. }
  86. /**
  87. * {@inheritDoc}
  88. */
  89. public function getInstallationSource()
  90. {
  91. return $this->installationSource;
  92. }
  93. /**
  94. * @param string $type
  95. */
  96. public function setSourceType($type)
  97. {
  98. $this->sourceType = $type;
  99. }
  100. /**
  101. * {@inheritDoc}
  102. */
  103. public function getSourceType()
  104. {
  105. return $this->sourceType;
  106. }
  107. /**
  108. * @param string $url
  109. */
  110. public function setSourceUrl($url)
  111. {
  112. $this->sourceUrl = $url;
  113. }
  114. /**
  115. * {@inheritDoc}
  116. */
  117. public function getSourceUrl()
  118. {
  119. return $this->sourceUrl;
  120. }
  121. /**
  122. * @param string $reference
  123. */
  124. public function setSourceReference($reference)
  125. {
  126. $this->sourceReference = $reference;
  127. }
  128. /**
  129. * {@inheritDoc}
  130. */
  131. public function getSourceReference()
  132. {
  133. return $this->sourceReference;
  134. }
  135. /**
  136. * @param string $type
  137. */
  138. public function setDistType($type)
  139. {
  140. $this->distType = $type;
  141. }
  142. /**
  143. * {@inheritDoc}
  144. */
  145. public function getDistType()
  146. {
  147. return $this->distType;
  148. }
  149. /**
  150. * @param string $url
  151. */
  152. public function setDistUrl($url)
  153. {
  154. $this->distUrl = $url;
  155. }
  156. /**
  157. * {@inheritDoc}
  158. */
  159. public function getDistUrl()
  160. {
  161. return $this->distUrl;
  162. }
  163. /**
  164. * @param string $reference
  165. */
  166. public function setDistReference($reference)
  167. {
  168. $this->distReference = $reference;
  169. }
  170. /**
  171. * {@inheritDoc}
  172. */
  173. public function getDistReference()
  174. {
  175. return $this->distReference;
  176. }
  177. /**
  178. * @param string $url
  179. */
  180. public function setDistSha1Checksum($sha1checksum)
  181. {
  182. $this->distSha1Checksum = $sha1checksum;
  183. }
  184. /**
  185. * {@inheritDoc}
  186. */
  187. public function getDistSha1Checksum()
  188. {
  189. return $this->distSha1Checksum;
  190. }
  191. /**
  192. * Set the release type
  193. *
  194. * @param string $releaseType
  195. */
  196. public function setReleaseType($releaseType)
  197. {
  198. $this->releaseType = $releaseType;
  199. }
  200. /**
  201. * {@inheritDoc}
  202. */
  203. public function getReleaseType()
  204. {
  205. return $this->releaseType;
  206. }
  207. /**
  208. * Set the version
  209. *
  210. * @param string $version
  211. */
  212. public function setVersion($version)
  213. {
  214. $this->version = $version;
  215. }
  216. /**
  217. * {@inheritDoc}
  218. */
  219. public function getVersion()
  220. {
  221. return $this->version;
  222. }
  223. /**
  224. * Set the license
  225. *
  226. * @param string $license
  227. */
  228. public function setLicense($license)
  229. {
  230. $this->license = $license;
  231. }
  232. /**
  233. * {@inheritDoc}
  234. */
  235. public function getLicense()
  236. {
  237. return $this->license;
  238. }
  239. /**
  240. * Set the required packages
  241. *
  242. * @param array $requires A set of package links
  243. */
  244. public function setRequires(array $requires)
  245. {
  246. $this->requires = $requires;
  247. }
  248. /**
  249. * {@inheritDoc}
  250. */
  251. public function getRequires()
  252. {
  253. return $this->requires;
  254. }
  255. /**
  256. * Set the conflicting packages
  257. *
  258. * @param array $conflicts A set of package links
  259. */
  260. public function setConflicts(array $conflicts)
  261. {
  262. $this->conflicts = $conflicts;
  263. }
  264. /**
  265. * {@inheritDoc}
  266. */
  267. public function getConflicts()
  268. {
  269. return $this->conflicts;
  270. }
  271. /**
  272. * Set the provided virtual packages
  273. *
  274. * @param array $conflicts A set of package links
  275. */
  276. public function setProvides(array $provides)
  277. {
  278. $this->provides = $provides;
  279. }
  280. /**
  281. * {@inheritDoc}
  282. */
  283. public function getProvides()
  284. {
  285. return $this->provides;
  286. }
  287. /**
  288. * Set the packages this one replaces
  289. *
  290. * @param array $conflicts A set of package links
  291. */
  292. public function setReplaces(array $replaces)
  293. {
  294. $this->replaces = $replaces;
  295. }
  296. /**
  297. * {@inheritDoc}
  298. */
  299. public function getReplaces()
  300. {
  301. return $this->replaces;
  302. }
  303. /**
  304. * Set the recommended packages
  305. *
  306. * @param array $conflicts A set of package links
  307. */
  308. public function setRecommends(array $recommends)
  309. {
  310. $this->recommends = $recommends;
  311. }
  312. /**
  313. * {@inheritDoc}
  314. */
  315. public function getRecommends()
  316. {
  317. return $this->recommends;
  318. }
  319. /**
  320. * Set the suggested packages
  321. *
  322. * @param array $conflicts A set of package links
  323. */
  324. public function setSuggests(array $suggests)
  325. {
  326. $this->suggests = $suggests;
  327. }
  328. /**
  329. * {@inheritDoc}
  330. */
  331. public function getSuggests()
  332. {
  333. return $this->suggests;
  334. }
  335. }