Soshot/app/Controllers/Result.php

39 lines
998 B
PHP
Raw Normal View History

2023-06-21 11:42:36 +02:00
<?php
namespace App\Controllers;
use App\Soshot\GetThumb;
use App\Soshot\GetFav;
use App\Soshot\GetOg;
use App\Utils\Error;
class Result {
public function index($params, $conf) {
if (
!isset($params->type) ||
!isset($params->hmac) ||
!isset($params->url)
) {
$error = new Error();
$error->index((object)['status' => 400, 'message' => 'Missing parameters']);
}
if (!in_array($params->type, $conf->permitType)) {
$error = new Error();
$error->index((object)['status' => 400, 'message' => 'Wrong type']);
}
if ($params->type === 'fav') {
$favicon = new GetFav($params, $conf);
$favicon->show();
} elseif ($params->type === 'og') {
$favicon = new GetOg($params, $conf);
$favicon->show();
} else {
$result = new GetThumb($params, $conf);
$result->show();
}
}
}