1 | <?php |
||
18 | class MongoGridFSFile |
||
1 ignored issue
–
show
|
|||
19 | { |
||
20 | /** |
||
21 | * @link http://php.net/manual/en/class.mongogridfsfile.php#mongogridfsfile.props.file |
||
22 | * @var array |
||
23 | */ |
||
24 | public $file; |
||
25 | |||
26 | /** |
||
27 | * @link http://php.net/manual/en/class.mongogridfsfile.php#mongogridfsfile.props.gridfs |
||
28 | * @var $gridfs |
||
29 | */ |
||
30 | protected $gridfs; |
||
31 | |||
32 | /** |
||
33 | * @link http://php.net/manual/en/mongogridfsfile.construct.php |
||
34 | * @param MongoGridFS $gridfs The parent MongoGridFS instance |
||
35 | * @param array $file A file from the database |
||
36 | * @return MongoGridFSFile Returns a new MongoGridFSFile |
||
37 | */ |
||
38 | public function __construct(MongoGridFS $gridfs, array $file) |
||
39 | { |
||
40 | $this->gridfs = $gridfs; |
||
41 | $this->file = $file; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Returns this file's filename |
||
46 | * @link http://php.net/manual/en/mongogridfsfile.getfilename.php |
||
47 | * @return string Returns the filename |
||
48 | */ |
||
49 | public function getFilename() |
||
50 | { |
||
51 | if (isset($this->file['filename'])) { |
||
52 | return $this->file['filename']; |
||
53 | } |
||
54 | return null; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Returns this file's size |
||
59 | * @link http://php.net/manual/en/mongogridfsfile.getsize.php |
||
60 | * @return int Returns this file's size |
||
61 | */ |
||
62 | public function getSize() |
||
66 | |||
67 | /** |
||
68 | * Writes this file to the filesystem |
||
69 | * @link http://php.net/manual/en/mongogridfsfile.write.php |
||
70 | * @param string $filename The location to which to write the file (path+filename+extension). If none is given, the stored filename will be used. |
||
71 | * @return int Returns the number of bytes written |
||
72 | */ |
||
73 | public function write($filename = null) |
||
87 | |||
88 | /** |
||
89 | * This will load the file into memory. If the file is bigger than your memory, this will cause problems! |
||
90 | * @link http://php.net/manual/en/mongogridfsfile.getbytes.php |
||
91 | * @return string Returns a string of the bytes in the file |
||
92 | */ |
||
93 | public function getBytes() |
||
102 | |||
103 | /** |
||
104 | * This method returns a stream resource that can be used to read the stored file with all file functions in PHP. |
||
105 | * The contents of the file are pulled out of MongoDB on the fly, so that the whole file does not have to be loaded into memory first. |
||
106 | * At most two GridFSFile chunks will be loaded in memory. |
||
107 | * |
||
108 | * @link http://php.net/manual/en/mongogridfsfile.getresource.php |
||
109 | * @return resource Returns a resource that can be used to read the file with |
||
110 | */ |
||
111 | public function getResource() |
||
118 | |||
119 | private function writeFromRessource($handle) |
||
132 | |||
133 | private function getChunks() |
||
141 | |||
142 | } |
||
143 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.