| 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) |
||
| 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() |
||
| 56 | |||
| 57 | |||
| 58 | /** |
||
| 59 | * Returns this file's size |
||
| 60 | * @link http://php.net/manual/en/mongogridfsfile.getsize.php |
||
| 61 | * @return int Returns this file's size |
||
| 62 | */ |
||
| 63 | public function getSize() |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Writes this file to the filesystem |
||
| 70 | * @link http://php.net/manual/en/mongogridfsfile.write.php |
||
| 71 | * @param string $filename The location to which to write the file (path+filename+extension). If none is given, the stored filename will be used. |
||
| 72 | * @return int Returns the number of bytes written |
||
| 73 | */ |
||
| 74 | public function write($filename = null) |
||
| 88 | |||
| 89 | |||
| 90 | /** |
||
| 91 | * This will load the file into memory. If the file is bigger than your memory, this will cause problems! |
||
| 92 | * @link http://php.net/manual/en/mongogridfsfile.getbytes.php |
||
| 93 | * @return string Returns a string of the bytes in the file |
||
| 94 | */ |
||
| 95 | public function getBytes() |
||
| 104 | |||
| 105 | /** |
||
| 106 | * This method returns a stream resource that can be used to read the stored file with all file functions in PHP. |
||
| 107 | * 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. |
||
| 108 | * At most two GridFSFile chunks will be loaded in memory. |
||
| 109 | * |
||
| 110 | * @link http://php.net/manual/en/mongogridfsfile.getresource.php |
||
| 111 | * @return resource Returns a resource that can be used to read the file with |
||
| 112 | */ |
||
| 113 | public function getResource() |
||
| 120 | |||
| 121 | |||
| 122 | private function writeFromRessource($handle) |
||
| 135 | |||
| 136 | private function getChunks() |
||
| 144 | |||
| 145 | } |
||
| 146 |
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.