<?php

namespace App\Core;

class View
{

  private array $shared = [];

  public function share(string $key, mixed $value): void
  {
    $this->shared[$key] = $value;
  }

  public function renderAdminPage(string $view, array $data = []): void
  {
    extract($data);

    ob_start();

    require __DIR__ . "/../Views/{$view}.php";
    $content = ob_get_clean();

    require __DIR__ . "/../Views/layouts/admin/index.php";
  }

  public function renderUserPage(string $view, array $data = []): void
  {
    extract($data);

    ob_start();

    require __DIR__ . "/../Views/{$view}.php";
    $content = ob_get_clean();

    require __DIR__ . "/../Views/layouts/user/index.php";
  }

  public function renderAuthPage(string $view, array $data = []): void
  {
    extract($data);

    ob_start();

    require __DIR__ . "/../Views/{$view}.php";
  }

  public function partial(string $view, array $data = []): void
  {
    extract($data);

    require __DIR__ . "/../Views/{$view}.php";
  }
}
