UploadedFile.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
  11. use Psr\Http\Message\UploadedFileInterface;
  12. /**
  13. * @author Kévin Dunglas <dunglas@gmail.com>
  14. */
  15. class UploadedFile implements UploadedFileInterface
  16. {
  17. private $filePath;
  18. private $size;
  19. private $error;
  20. private $clientFileName;
  21. private $clientMediaType;
  22. public function __construct($filePath, $size = null, $error = UPLOAD_ERR_OK, $clientFileName = null, $clientMediaType = null)
  23. {
  24. $this->filePath = $filePath;
  25. $this->size = $size;
  26. $this->error = $error;
  27. $this->clientFileName = $clientFileName;
  28. $this->clientMediaType = $clientMediaType;
  29. }
  30. public function getStream()
  31. {
  32. throw new \RuntimeException('No stream is available.');
  33. }
  34. public function moveTo($targetPath)
  35. {
  36. rename($this->filePath, $targetPath);
  37. }
  38. public function getSize()
  39. {
  40. return $this->size;
  41. }
  42. public function getError()
  43. {
  44. return $this->error;
  45. }
  46. public function getClientFilename()
  47. {
  48. return $this->clientFileName;
  49. }
  50. public function getClientMediaType()
  51. {
  52. return $this->clientMediaType;
  53. }
  54. }