<?php

namespace Helpers\Additional\Externe;

use Skeleton\Router;

final class Externe
{
    
    private \PDO $pdo;

    public function __construct(\PDO $pdo)
    {
        $this->pdo = $pdo;
    }
    
    /**
     * getMenu
     *
     * @param  Router $router
     * @param  string $menuActive
     * @param  string $module
     * @return array<mixed>|string
     */
    public function getMenu(Router $router, string $menuActive, string $module, string $type = 'Left')
    {

        $namespace = "Modules\\Additional\\Externe\\Menu\\".$type."\\".$module;
        
        if (class_exists($namespace)) {
            return $namespace::generate($this->pdo, $router, $menuActive);
        }
        
        return $type == 'Left'? [] : '';
    }

    
    /**
     * getMenuLeft
     *
     * @param  Router $router
     * @param  string $menuActive
     * @param  string $module
     * @return array<mixed>|string
     */
    public function getMenuLeft(Router $router, string $menuActive, string $module)
    {
        return $this->getMenu($router, $menuActive, $module);
    }
    
    /**
     * getMenuLeft
     *
     * @param  Router $router
     * @param  string $menuActive
     * @param  string $module
     * @return array<mixed>|string
     */
    public function getMenuTop(Router $router, string $menuActive, string $module)
    {
        return $this->getMenu($router, $menuActive, $module, 'Top');
    }
}
