2021-08-24 20:29:26 +01:00
|
|
|
<?php
|
|
|
|
|
2021-10-10 09:26:18 +01:00
|
|
|
declare(strict_types = 1);
|
|
|
|
|
2021-10-04 17:00:58 +01:00
|
|
|
namespace Plugin\ActivityPub\Util\Response;
|
2021-08-24 20:29:26 +01:00
|
|
|
|
2021-10-10 09:26:18 +01:00
|
|
|
use Exception;
|
2021-10-04 17:00:58 +01:00
|
|
|
use Plugin\ActivityPub\Util\Model\EntityToType\EntityToType;
|
2021-08-24 20:29:26 +01:00
|
|
|
|
|
|
|
abstract class AbstractResponse
|
|
|
|
{
|
|
|
|
/**
|
2021-09-06 23:47:28 +01:00
|
|
|
* param Type $type // What is this `Type`
|
|
|
|
*
|
2021-10-10 09:26:18 +01:00
|
|
|
* @param int $status The response status code
|
2021-08-24 20:29:26 +01:00
|
|
|
*
|
2021-10-10 09:26:18 +01:00
|
|
|
* @throws Exception
|
2021-08-24 20:29:26 +01:00
|
|
|
*/
|
|
|
|
public static function handle($type, int $status = 200): TypeResponse
|
|
|
|
{
|
|
|
|
return new TypeResponse(
|
|
|
|
data: EntityToType::translate($type),
|
2021-10-10 09:26:18 +01:00
|
|
|
status: $status,
|
2021-08-24 20:29:26 +01:00
|
|
|
);
|
|
|
|
}
|
2021-09-06 23:47:28 +01:00
|
|
|
}
|