MemoryPackage.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Composer\DependencyResolver;
  11. /**
  12. * A package with setters for all members to create it dynamically in memory
  13. *
  14. * @author Nils Adermann <naderman@naderman.de>
  15. */
  16. class MemoryPackage extends Package
  17. {
  18. protected $releaseType;
  19. protected $version;
  20. protected $requires = array();
  21. protected $conflicts = array();
  22. protected $provides = array();
  23. protected $replaces = array();
  24. protected $recommends = array();
  25. protected $suggests = array();
  26. /**
  27. * Creates a new in memory package.
  28. *
  29. * @param string $name The package's name
  30. * @param string $version The package's version
  31. * @param string $releaseType The package's release type (beta/rc/stable)
  32. * @param int $id A positive unique id, zero to auto generate
  33. */
  34. public function __construct($name, $version, $releaseType = 'stable', $id = 0)
  35. {
  36. parent::__construct($name, $id);
  37. $this->releaseType = $releaseType;
  38. $this->version = $version;
  39. }
  40. /**
  41. * Set the release type
  42. *
  43. * @param string $releaseType
  44. */
  45. public function setReleaseType($releaseType)
  46. {
  47. $this->releaseType = $releaseType;
  48. }
  49. /**
  50. * {@inheritDoc}
  51. */
  52. public function getReleaseType()
  53. {
  54. return $this->releaseType;
  55. }
  56. /**
  57. * Set the version
  58. *
  59. * @param string $version
  60. */
  61. public function setVersion($version)
  62. {
  63. $this->version = $version;
  64. }
  65. /**
  66. * {@inheritDoc}
  67. */
  68. public function getVersion()
  69. {
  70. return $this->version;
  71. }
  72. /**
  73. * Set the required packages
  74. *
  75. * @param array $requires A set of package relations
  76. */
  77. public function setRequires(array $requires)
  78. {
  79. $this->requires = $requires;
  80. }
  81. /**
  82. * {@inheritDoc}
  83. */
  84. public function getRequires()
  85. {
  86. return $this->requires;
  87. }
  88. /**
  89. * Set the conflicting packages
  90. *
  91. * @param array $conflicts A set of package relations
  92. */
  93. public function setConflicts(array $conflicts)
  94. {
  95. $this->conflicts = $conflicts;
  96. }
  97. /**
  98. * {@inheritDoc}
  99. */
  100. public function getConflicts()
  101. {
  102. return $this->conflicts;
  103. }
  104. /**
  105. * Set the provided virtual packages
  106. *
  107. * @param array $conflicts A set of package relations
  108. */
  109. public function setProvides(array $provides)
  110. {
  111. $this->provides = $provides;
  112. }
  113. /**
  114. * {@inheritDoc}
  115. */
  116. public function getProvides()
  117. {
  118. return $this->provides;
  119. }
  120. /**
  121. * Set the packages this one replaces
  122. *
  123. * @param array $conflicts A set of package relations
  124. */
  125. public function setReplaces(array $replaces)
  126. {
  127. $this->replaces = $replaces;
  128. }
  129. /**
  130. * {@inheritDoc}
  131. */
  132. public function getReplaces()
  133. {
  134. return $this->replaces;
  135. }
  136. /**
  137. * Set the recommended packages
  138. *
  139. * @param array $conflicts A set of package relations
  140. */
  141. public function setRecommends(array $recommends)
  142. {
  143. $this->recommends = $recommends;
  144. }
  145. /**
  146. * {@inheritDoc}
  147. */
  148. public function getRecommends()
  149. {
  150. return $this->recommends;
  151. }
  152. /**
  153. * Set the suggested packages
  154. *
  155. * @param array $conflicts A set of package relations
  156. */
  157. public function setSuggests(array $suggests)
  158. {
  159. $this->suggests = $suggests;
  160. }
  161. /**
  162. * {@inheritDoc}
  163. */
  164. public function getSuggests()
  165. {
  166. return $this->suggests;
  167. }
  168. }