RemoteFilesystemMock.php 932 B

1234567891011121314151617181920212223242526272829303132333435363738
  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\Test\Mock;
  12. use Composer\Util\RemoteFilesystem;
  13. /**
  14. * Remote filesystem mock
  15. */
  16. class RemoteFilesystemMock extends RemoteFilesystem
  17. {
  18. /**
  19. * @param array $contentMap associative array of locations and content
  20. */
  21. public function __construct(array $contentMap)
  22. {
  23. $this->contentMap = $contentMap;
  24. }
  25. public function getContents($originUrl, $fileUrl, $progress = true)
  26. {
  27. if(!empty($this->contentMap[$fileUrl]))
  28. return $this->contentMap[$fileUrl];
  29. throw new \Composer\Downloader\TransportException('The "'.$fileUrl.'" file could not be downloaded (NOT FOUND)', 404);
  30. }
  31. }