<?php

namespace App\Services;

use App\Core\Database;

class HomepageRecommendationService
{

public static function analyze(
int $conferenceId
): array
{

$db=
Database::getInstance();

$out=[];

/*
sections
*/

$s=
$db
->prepare("

SELECT
COUNT(*)

FROM
conference_home_sections

WHERE conference_id=?

");

$s
->execute([

$conferenceId

]);

$sections=
(int)
$s
->fetchColumn();

if(
$sections<6
){

$out[]=[

'type'=>'content',

'severity'=>'medium',

'message'=>

'Add more homepage sections'

];

}

/*
hero
*/

$h=
$db
->prepare("

SELECT COUNT(*)

FROM conference_homepage_blocks

WHERE conference_id=?

AND block_key='hero'

");

$h
->execute([

$conferenceId

]);

if(
!(int)
$h
->fetchColumn()
){

$out[]=[

'type'=>'seo',

'severity'=>'high',

'message'=>

'Hero section missing'

];

}

return
$out;

}

}
