forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileObjectTransformer.php
More file actions
34 lines (30 loc) · 1.03 KB
/
FileObjectTransformer.php
File metadata and controls
34 lines (30 loc) · 1.03 KB
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
<?php
namespace Pterodactyl\Transformers\Api\Client;
use Carbon\Carbon;
use Illuminate\Support\Arr;
class FileObjectTransformer extends BaseClientTransformer
{
/**
* Transform a file object response from the daemon into a standardized response.
*
* @return array
*/
public function transform(array $item)
{
return [
'name' => Arr::get($item, 'name'),
'mode' => Arr::get($item, 'mode'),
'mode_bits' => Arr::get($item, 'mode_bits'),
'size' => Arr::get($item, 'size'),
'is_file' => Arr::get($item, 'file', true),
'is_symlink' => Arr::get($item, 'symlink', false),
'mimetype' => Arr::get($item, 'mime', 'application/octet-stream'),
'created_at' => Carbon::parse(Arr::get($item, 'created', ''))->toIso8601String(),
'modified_at' => Carbon::parse(Arr::get($item, 'modified', ''))->toIso8601String(),
];
}
public function getResourceName(): string
{
return 'file_object';
}
}