1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 17:12:30 +01:00
Pterodactyl-Panel/app/Transformers/Api/Client/FileObjectTransformer.php
Matthew Penner cbcf62086f
Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
2022-10-14 10:59:20 -06:00

33 lines
1.0 KiB
PHP

<?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.
*/
public function transform(array $item): array
{
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', ''))->toAtomString(),
'modified_at' => Carbon::parse(Arr::get($item, 'modified', ''))->toAtomString(),
];
}
public function getResourceName(): string
{
return 'file_object';
}
}