Version 1
[yaffs-website] / vendor / symfony / psr-http-message-bridge / Tests / Fixtures / UploadedFile.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
13
14 use Psr\Http\Message\UploadedFileInterface;
15
16 /**
17  * @author Kévin Dunglas <dunglas@gmail.com>
18  */
19 class UploadedFile implements UploadedFileInterface
20 {
21     private $filePath;
22     private $size;
23     private $error;
24     private $clientFileName;
25     private $clientMediaType;
26
27     public function __construct($filePath, $size = null, $error = UPLOAD_ERR_OK, $clientFileName = null, $clientMediaType = null)
28     {
29         $this->filePath = $filePath;
30         $this->size = $size;
31         $this->error = $error;
32         $this->clientFileName = $clientFileName;
33         $this->clientMediaType = $clientMediaType;
34     }
35
36     public function getStream()
37     {
38         throw new \RuntimeException('No stream is available.');
39     }
40
41     public function moveTo($targetPath)
42     {
43         rename($this->filePath, $targetPath);
44     }
45
46     public function getSize()
47     {
48         return $this->size;
49     }
50
51     public function getError()
52     {
53         return $this->error;
54     }
55
56     public function getClientFilename()
57     {
58         return $this->clientFileName;
59     }
60
61     public function getClientMediaType()
62     {
63         return $this->clientMediaType;
64     }
65 }