Skip to content
Snippets Groups Projects
RequeteView.php 1.07 KiB
<?php

namespace bdd\views;

use Slim\Slim;

class RequeteView
{

    protected $tab, $app;

    public function __construct($t)
    {
        $this->tab = $t;
        $this->app = Slim::getInstance();
    }

    public function render($type)
    {
        $html = "";
        switch ($type) {
            case 1:
                $html = $this->default();
                break;
            default:
                $html = $this->notFound();
                break;
        }
        echo $html;
    }

    private function notFound()
    {
        return <<<RES
    <!doctype html>

    <html lang="fr">
    <head>
        <meta charset="utf-8">
    </head>
    <body>
        <p>data not found</p>
    </body>
    </html>
RES;
    }

    private function default()
    {
        $res = <<<RES
    <!doctype html>

    <html lang="fr">
    <head>
        <meta charset="utf-8">
    </head>
    <body>

RES;
        foreach ($this->tab as $key => $value) {
            $res .= <<<RES
    $key:$value<br>
RES;
        }
        $res .= <<<RES
    </body>
    </html>
RES;
        return $res;
    }
}