UninstallOperation.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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\DependencyResolver\Operation;
  12. use Composer\Package\PackageInterface;
  13. /**
  14. * Solver uninstall operation.
  15. *
  16. * @author Konstantin Kudryashov <ever.zet@gmail.com>
  17. */
  18. class UninstallOperation extends SolverOperation
  19. {
  20. protected $package;
  21. /**
  22. * Initializes operation.
  23. *
  24. * @param PackageInterface $package package instance
  25. * @param string $reason operation reason
  26. */
  27. public function __construct(PackageInterface $package, $reason = null)
  28. {
  29. parent::__construct($reason);
  30. $this->package = $package;
  31. }
  32. /**
  33. * Returns package instance.
  34. *
  35. * @return PackageInterface
  36. */
  37. public function getPackage()
  38. {
  39. return $this->package;
  40. }
  41. /**
  42. * Returns operation type.
  43. *
  44. * @return string
  45. */
  46. public function getOperationType()
  47. {
  48. return 'uninstall';
  49. }
  50. /**
  51. * {@inheritDoc}
  52. */
  53. public function show($lock)
  54. {
  55. return ($lock ? 'Removing ' : 'Uninstalling ').$this->package->getPrettyName().' ('.$this->package->getFullPrettyVersion().')';
  56. }
  57. /**
  58. * {@inheritDoc}
  59. */
  60. public function __toString()
  61. {
  62. return $this->show(false);
  63. }
  64. }