| 1 | <?php |
||
| 16 | class MongoGridFSFile |
||
|
1 ignored issue
–
show
|
|||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @link http://php.net/manual/en/class.mongogridfsfile.php#mongogridfsfile.props.file |
||
| 20 | * @var array |
||
| 21 | */ |
||
| 22 | public $file; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @link http://php.net/manual/en/class.mongogridfsfile.php#mongogridfsfile.props.gridfs |
||
| 26 | * @var $gridfs |
||
| 27 | */ |
||
| 28 | protected $gridfs; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @link http://php.net/manual/en/mongogridfsfile.construct.php |
||
| 32 | * @param MongoGridFS $gridfs The parent MongoGridFS instance |
||
| 33 | * @param array $file A file from the database |
||
| 34 | * @return MongoGridFSFile Returns a new MongoGridFSFile |
||
| 35 | */ |
||
| 36 | public function __construct(MongoGridFS $gridfs, array $file) |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Returns this file's filename |
||
| 44 | * @link http://php.net/manual/en/mongogridfsfile.getfilename.php |
||
| 45 | * @return string Returns the filename |
||
| 46 | */ |
||
| 47 | public function getFilename() |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Returns this file's size |
||
| 57 | * @link http://php.net/manual/en/mongogridfsfile.getsize.php |
||
| 58 | * @return int Returns this file's size |
||
| 59 | */ |
||
| 60 | public function getSize() |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Writes this file to the filesystem |
||
| 67 | * @link http://php.net/manual/en/mongogridfsfile.write.php |
||
| 68 | * @param string $filename The location to which to write the file (path+filename+extension). If none is given, the stored filename will be used. |
||
| 69 | * @return int Returns the number of bytes written |
||
| 70 | */ |
||
| 71 | public function write($filename = null) |
||
| 85 | |||
| 86 | /** |
||
| 87 | * This will load the file into memory. If the file is bigger than your memory, this will cause problems! |
||
| 88 | * @link http://php.net/manual/en/mongogridfsfile.getbytes.php |
||
| 89 | * @return string Returns a string of the bytes in the file |
||
| 90 | */ |
||
| 91 | public function getBytes() |
||
| 100 | |||
| 101 | /** |
||
| 102 | * This method returns a stream resource that can be used to read the stored file with all file functions in PHP. |
||
| 103 | * 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. |
||
| 104 | * At most two GridFSFile chunks will be loaded in memory. |
||
| 105 | * |
||
| 106 | * @link http://php.net/manual/en/mongogridfsfile.getresource.php |
||
| 107 | * @return resource Returns a resource that can be used to read the file with |
||
| 108 | */ |
||
| 109 | public function getResource() |
||
| 116 | |||
| 117 | private function writeFromRessource($handle) |
||
| 130 | |||
| 131 | private function getChunks() |
||
| 139 | |||
| 140 | } |
||
| 141 |
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.