1
0
Fork 0
pixelfed/app/Transformer/Api/Mastodon/v1/MentionTransformer.php

22 lines
549 B
PHP
Raw Normal View History

2019-09-26 07:30:15 +00:00
<?php
namespace App\Transformer\Api\Mastodon\v1;
use App\Profile;
use League\Fractal;
class MentionTransformer extends Fractal\TransformerAbstract
{
public function transform(Profile $profile)
{
2022-01-03 06:26:18 +00:00
$local = $profile->domain == null;
$username = $local ? $profile->username : explode('@', substr($profile->username, 1))[0];
2019-09-26 07:30:15 +00:00
return [
'id' => (string) $profile->id,
'url' => $profile->url(),
'username' => $profile->username,
2022-01-03 06:26:18 +00:00
'acct' => $username,
2019-09-26 07:30:15 +00:00
];
}
}