-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathFile.php
60 lines (52 loc) · 1.14 KB
/
File.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace Kunnu\Dropbox\Models;
use Kunnu\Dropbox\DropboxFile;
class File extends BaseModel
{
/**
* The file contents
*
* @var string|DropboxFile
*/
protected $contents;
/**
* File Metadata
*
* @var \Kunnu\Dropbox\Models\FileMetadata
*/
protected $metadata;
/**
* Create a new File instance
*
* @param array $data
* @param string|DropboxFile $contents
*/
public function __construct(array $data, $contents)
{
parent::__construct($data);
$this->contents = $contents;
$this->metadata = new FileMetadata($data);
}
/**
* The metadata for the file
*
* @return \Kunnu\Dropbox\Models\FileMetadata
*/
public function getMetadata()
{
return $this->metadata;
}
/**
* Get the file contents
*
* @return string
* @throws \Kunnu\Dropbox\Exceptions\DropboxClientException
*/
public function getContents()
{
if ($this->contents instanceof DropboxFile) {
return $this->contents->getContents();
}
return $this->contents;
}
}