1 | <?php |
||
2 | |||
3 | namespace NStack\Models; |
||
4 | |||
5 | /** |
||
6 | * Class File |
||
7 | * |
||
8 | * @package NStack\Models |
||
9 | * @author Tiago Araujo <[email protected]> |
||
10 | */ |
||
11 | class File extends Model |
||
12 | { |
||
13 | /** @var int */ |
||
14 | protected $id; |
||
15 | |||
16 | /** @var string */ |
||
17 | protected $name; |
||
18 | |||
19 | /** @var string */ |
||
20 | protected $tags; |
||
21 | |||
22 | /** @var string */ |
||
23 | protected $privacy; |
||
24 | |||
25 | /** @var string */ |
||
26 | protected $goneAt; |
||
27 | |||
28 | /** @var string */ |
||
29 | protected $mime; |
||
30 | |||
31 | /** @var int */ |
||
32 | protected $size; |
||
33 | |||
34 | /** @var string */ |
||
35 | protected $password; |
||
36 | |||
37 | /** @var string */ |
||
38 | protected $url; |
||
39 | |||
40 | /** @var string */ |
||
41 | protected $cdnUrl; |
||
42 | |||
43 | /** @var string */ |
||
44 | protected $showUrl; |
||
45 | |||
46 | /** @var string */ |
||
47 | protected $downloadUrl; |
||
48 | |||
49 | /** |
||
50 | * parse |
||
51 | * |
||
52 | * @param array $data |
||
53 | */ |
||
54 | 2 | public function parse(array $data) |
|
55 | { |
||
56 | 2 | $this->id = (int)$data['id']; |
|
57 | 2 | $this->name = (string)$data['name']; |
|
58 | 2 | $this->tags = (string)$data['tags']; |
|
59 | 2 | $this->privacy = (string)$data['privacy']; |
|
60 | 2 | $this->goneAt = (string)$data['gone_at']; |
|
61 | 2 | $this->size = (string)$data['size']; |
|
0 ignored issues
–
show
|
|||
62 | 2 | $this->mime = (string)$data['mime']; |
|
63 | 2 | $this->password = (string)$data['password']; |
|
64 | 2 | $this->url = (string)$data['url']; |
|
65 | 2 | $this->cdnUrl = (string)$data['cdn_url']; |
|
66 | 2 | $this->showUrl = (string)$data['show_url']; |
|
67 | 2 | $this->downloadUrl = (string)$data['download_url']; |
|
68 | 2 | } |
|
69 | |||
70 | /** |
||
71 | * toArray |
||
72 | * |
||
73 | * @return array |
||
74 | */ |
||
75 | public function toArray(): array |
||
76 | { |
||
77 | return [ |
||
78 | 'id' => $this->id, |
||
79 | 'name' => $this->name, |
||
80 | 'tags' => $this->tags, |
||
81 | 'privacy' => $this->privacy, |
||
82 | 'gone_at' => $this->goneAt, |
||
83 | 'size' => $this->size, |
||
84 | 'password' => $this->password, |
||
85 | 'url' => $this->url, |
||
86 | 'cdn_url' => $this->cdnUrl, |
||
87 | 'show_url' => $this->showUrl, |
||
88 | 'download_url' => $this->downloadUrl, |
||
89 | 'mime' => $this->mime, |
||
90 | ]; |
||
91 | } |
||
92 | } |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.