MemoryPackage.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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 $targetDir;
  21. protected $installationSource;
  22. protected $sourceType;
  23. protected $sourceUrl;
  24. protected $sourceReference;
  25. protected $distType;
  26. protected $distUrl;
  27. protected $distReference;
  28. protected $distSha1Checksum;
  29. protected $version;
  30. protected $prettyVersion;
  31. protected $repositories;
  32. protected $license = array();
  33. protected $releaseDate;
  34. protected $keywords;
  35. protected $authors;
  36. protected $description;
  37. protected $homepage;
  38. protected $extra = array();
  39. protected $binaries = array();
  40. protected $scripts = array();
  41. protected $requires = array();
  42. protected $conflicts = array();
  43. protected $provides = array();
  44. protected $replaces = array();
  45. protected $recommends = array();
  46. protected $suggests = array();
  47. protected $autoload = array();
  48. /**
  49. * Creates a new in memory package.
  50. *
  51. * @param string $name The package's name
  52. * @param string $version The package's version
  53. * @param string $prettyVersion The package's non-normalized version
  54. */
  55. public function __construct($name, $version, $prettyVersion)
  56. {
  57. parent::__construct($name);
  58. $this->version = $version;
  59. $this->prettyVersion = $prettyVersion;
  60. }
  61. /**
  62. * @param string $type
  63. */
  64. public function setType($type)
  65. {
  66. $this->type = $type;
  67. }
  68. /**
  69. * {@inheritDoc}
  70. */
  71. public function getType()
  72. {
  73. return $this->type ?: 'library';
  74. }
  75. /**
  76. * @param string $targetDir
  77. */
  78. public function setTargetDir($targetDir)
  79. {
  80. $this->targetDir = $targetDir;
  81. }
  82. /**
  83. * {@inheritDoc}
  84. */
  85. public function getTargetDir()
  86. {
  87. return $this->targetDir;
  88. }
  89. /**
  90. * @param array $extra
  91. */
  92. public function setExtra(array $extra)
  93. {
  94. $this->extra = $extra;
  95. }
  96. /**
  97. * {@inheritDoc}
  98. */
  99. public function getExtra()
  100. {
  101. return $this->extra;
  102. }
  103. /**
  104. * @param array $binaries
  105. */
  106. public function setBinaries(array $binaries)
  107. {
  108. $this->binaries = $binaries;
  109. }
  110. /**
  111. * {@inheritDoc}
  112. */
  113. public function getBinaries()
  114. {
  115. return $this->binaries;
  116. }
  117. /**
  118. * @param array $scripts
  119. */
  120. public function setScripts(array $scripts)
  121. {
  122. $this->scripts = $scripts;
  123. }
  124. /**
  125. * {@inheritDoc}
  126. */
  127. public function getScripts()
  128. {
  129. return $this->scripts;
  130. }
  131. /**
  132. * {@inheritDoc}
  133. */
  134. public function setInstallationSource($type)
  135. {
  136. $this->installationSource = $type;
  137. }
  138. /**
  139. * {@inheritDoc}
  140. */
  141. public function getInstallationSource()
  142. {
  143. return $this->installationSource;
  144. }
  145. /**
  146. * @param string $type
  147. */
  148. public function setSourceType($type)
  149. {
  150. $this->sourceType = $type;
  151. }
  152. /**
  153. * {@inheritDoc}
  154. */
  155. public function getSourceType()
  156. {
  157. return $this->sourceType;
  158. }
  159. /**
  160. * @param string $url
  161. */
  162. public function setSourceUrl($url)
  163. {
  164. $this->sourceUrl = $url;
  165. }
  166. /**
  167. * {@inheritDoc}
  168. */
  169. public function getSourceUrl()
  170. {
  171. return $this->sourceUrl;
  172. }
  173. /**
  174. * @param string $reference
  175. */
  176. public function setSourceReference($reference)
  177. {
  178. $this->sourceReference = $reference;
  179. }
  180. /**
  181. * {@inheritDoc}
  182. */
  183. public function getSourceReference()
  184. {
  185. return $this->sourceReference;
  186. }
  187. /**
  188. * @param string $type
  189. */
  190. public function setDistType($type)
  191. {
  192. $this->distType = $type;
  193. }
  194. /**
  195. * {@inheritDoc}
  196. */
  197. public function getDistType()
  198. {
  199. return $this->distType;
  200. }
  201. /**
  202. * @param string $url
  203. */
  204. public function setDistUrl($url)
  205. {
  206. $this->distUrl = $url;
  207. }
  208. /**
  209. * {@inheritDoc}
  210. */
  211. public function getDistUrl()
  212. {
  213. return $this->distUrl;
  214. }
  215. /**
  216. * @param string $reference
  217. */
  218. public function setDistReference($reference)
  219. {
  220. $this->distReference = $reference;
  221. }
  222. /**
  223. * {@inheritDoc}
  224. */
  225. public function getDistReference()
  226. {
  227. return $this->distReference;
  228. }
  229. /**
  230. * @param string $sha1checksum
  231. */
  232. public function setDistSha1Checksum($sha1checksum)
  233. {
  234. $this->distSha1Checksum = $sha1checksum;
  235. }
  236. /**
  237. * {@inheritDoc}
  238. */
  239. public function getDistSha1Checksum()
  240. {
  241. return $this->distSha1Checksum;
  242. }
  243. /**
  244. * Set the repositories
  245. *
  246. * @param string $repositories
  247. */
  248. public function setRepositories($repositories)
  249. {
  250. $this->repositories = $repositories;
  251. }
  252. /**
  253. * {@inheritDoc}
  254. */
  255. public function getRepositories()
  256. {
  257. return $this->repositories;
  258. }
  259. /**
  260. * {@inheritDoc}
  261. */
  262. public function getVersion()
  263. {
  264. return $this->version;
  265. }
  266. /**
  267. * {@inheritDoc}
  268. */
  269. public function getPrettyVersion()
  270. {
  271. return $this->prettyVersion;
  272. }
  273. /**
  274. * Set the license
  275. *
  276. * @param array $license
  277. */
  278. public function setLicense(array $license)
  279. {
  280. $this->license = $license;
  281. }
  282. /**
  283. * {@inheritDoc}
  284. */
  285. public function getLicense()
  286. {
  287. return $this->license;
  288. }
  289. /**
  290. * Set the required packages
  291. *
  292. * @param array $requires A set of package links
  293. */
  294. public function setRequires(array $requires)
  295. {
  296. $this->requires = $requires;
  297. }
  298. /**
  299. * {@inheritDoc}
  300. */
  301. public function getRequires()
  302. {
  303. return $this->requires;
  304. }
  305. /**
  306. * Set the conflicting packages
  307. *
  308. * @param array $conflicts A set of package links
  309. */
  310. public function setConflicts(array $conflicts)
  311. {
  312. $this->conflicts = $conflicts;
  313. }
  314. /**
  315. * {@inheritDoc}
  316. */
  317. public function getConflicts()
  318. {
  319. return $this->conflicts;
  320. }
  321. /**
  322. * Set the provided virtual packages
  323. *
  324. * @param array $provides A set of package links
  325. */
  326. public function setProvides(array $provides)
  327. {
  328. $this->provides = $provides;
  329. }
  330. /**
  331. * {@inheritDoc}
  332. */
  333. public function getProvides()
  334. {
  335. return $this->provides;
  336. }
  337. /**
  338. * Set the packages this one replaces
  339. *
  340. * @param array $replaces A set of package links
  341. */
  342. public function setReplaces(array $replaces)
  343. {
  344. $this->replaces = $replaces;
  345. }
  346. /**
  347. * {@inheritDoc}
  348. */
  349. public function getReplaces()
  350. {
  351. return $this->replaces;
  352. }
  353. /**
  354. * Set the recommended packages
  355. *
  356. * @param array $recommends A set of package links
  357. */
  358. public function setRecommends(array $recommends)
  359. {
  360. $this->recommends = $recommends;
  361. }
  362. /**
  363. * {@inheritDoc}
  364. */
  365. public function getRecommends()
  366. {
  367. return $this->recommends;
  368. }
  369. /**
  370. * Set the suggested packages
  371. *
  372. * @param array $suggests A set of package links
  373. */
  374. public function setSuggests(array $suggests)
  375. {
  376. $this->suggests = $suggests;
  377. }
  378. /**
  379. * {@inheritDoc}
  380. */
  381. public function getSuggests()
  382. {
  383. return $this->suggests;
  384. }
  385. /**
  386. * Set the releaseDate
  387. *
  388. * @param DateTime $releaseDate
  389. */
  390. public function setReleasedate(\DateTime $releaseDate)
  391. {
  392. $this->releaseDate = $releaseDate;
  393. }
  394. /**
  395. * {@inheritDoc}
  396. */
  397. public function getReleaseDate()
  398. {
  399. return $this->releaseDate;
  400. }
  401. /**
  402. * Set the keywords
  403. *
  404. * @param array $keywords
  405. */
  406. public function setKeywords(array $keywords)
  407. {
  408. $this->keywords = $keywords;
  409. }
  410. /**
  411. * {@inheritDoc}
  412. */
  413. public function getKeywords()
  414. {
  415. return $this->keywords;
  416. }
  417. /**
  418. * Set the authors
  419. *
  420. * @param array $authors
  421. */
  422. public function setAuthors(array $authors)
  423. {
  424. $this->authors = $authors;
  425. }
  426. /**
  427. * {@inheritDoc}
  428. */
  429. public function getAuthors()
  430. {
  431. return $this->authors;
  432. }
  433. /**
  434. * Set the description
  435. *
  436. * @param string $description
  437. */
  438. public function setDescription($description)
  439. {
  440. $this->description = $description;
  441. }
  442. /**
  443. * {@inheritDoc}
  444. */
  445. public function getDescription()
  446. {
  447. return $this->description;
  448. }
  449. /**
  450. * Set the homepage
  451. *
  452. * @param string $homepage
  453. */
  454. public function setHomepage($homepage)
  455. {
  456. $this->homepage = $homepage;
  457. }
  458. /**
  459. * {@inheritDoc}
  460. */
  461. public function getHomepage()
  462. {
  463. return $this->homepage;
  464. }
  465. /**
  466. * Set the autoload mapping
  467. *
  468. * @param array $autoload Mapping of autoloading rules
  469. */
  470. public function setAutoload(array $autoload)
  471. {
  472. $this->autoload = $autoload;
  473. }
  474. /**
  475. * {@inheritDoc}
  476. */
  477. public function getAutoload()
  478. {
  479. return $this->autoload;
  480. }
  481. }