MemoryPackage.php 11 KB

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