2019-07-28 03:23:51 +00:00
|
|
|
<?php
|
|
|
|
|
2022-05-22 20:23:22 +00:00
|
|
|
namespace Pterodactyl\Transformers\Api\Client;
|
2019-07-28 03:23:51 +00:00
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
|
2022-05-22 20:23:22 +00:00
|
|
|
class FileObjectTransformer extends BaseClientTransformer
|
2019-07-28 03:23:51 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Transform a file object response from the daemon into a standardized response.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function transform(array $item): array
|
2019-07-28 03:23:51 +00:00
|
|
|
{
|
|
|
|
return [
|
2021-01-02 00:55:09 +00:00
|
|
|
'name' => Arr::get($item, 'name'),
|
2019-07-28 03:23:51 +00:00
|
|
|
'mode' => Arr::get($item, 'mode'),
|
2020-11-29 21:46:35 +00:00
|
|
|
'mode_bits' => Arr::get($item, 'mode_bits'),
|
2019-07-28 03:23:51 +00:00
|
|
|
'size' => Arr::get($item, 'size'),
|
|
|
|
'is_file' => Arr::get($item, 'file', true),
|
|
|
|
'is_symlink' => Arr::get($item, 'symlink', false),
|
2020-08-30 17:25:48 +00:00
|
|
|
'mimetype' => Arr::get($item, 'mime', 'application/octet-stream'),
|
2022-10-14 16:59:20 +00:00
|
|
|
'created_at' => Carbon::parse(Arr::get($item, 'created', ''))->toAtomString(),
|
|
|
|
'modified_at' => Carbon::parse(Arr::get($item, 'modified', ''))->toAtomString(),
|
2019-07-28 03:23:51 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getResourceName(): string
|
|
|
|
{
|
|
|
|
return 'file_object';
|
|
|
|
}
|
|
|
|
}
|