MemoryPackage.php 11 KB

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