<?php

/*
 * Copyright (C) 2021 Echedey López Romero <elr@disroot.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

class Comment {

    private string $Id;
    private string $UserId;
    private string $Summary;
    private string $Date;
    private string $Content;

    public function __construct(string $Id, string $UserId, string $Summary, string $Date, string $Content) {
        $this->Id = $Id;
        $this->UserId = $UserId;
        $this->Summary = $Summary;
        $this->Date = $Date;
        $this->Content = $Content;
    }

    public function GetId(): string {
        return $this->Id;
    }

    public function GetUserId(): string {
        return $this->UserId;
    }

    public function GetSummary(): string {
        return $this->Summary;
    }

    public function GetDate(): string {
        return $this->Date;
    }

    public function GetContent(): string {
        return $this->Content;
    }

    public function SetId(string $Id): void {
        $this->Id = $Id;
    }

    public function SetUserId(string $UserId): void {
        $this->UserId = $UserId;
    }

    public function SetSummary(string $Summary): void {
        $this->Summary = $Summary;
    }

    public function SetDate(string $Date): void {
        $this->Date = $Date;
    }

    public function SetContent(string $Content): void {
        $this->Content = $Content;
    }
    
    public function Render(string $UserName): string {
        $HTML = '';
        
        $HTML .= '<div>' . PHP_EOL;
        $HTML .= '<span><a href=".?user=' . $this->UserId . '">' . $UserName . '</a></span>' . PHP_EOL;
        $HTML .= '<span>' . $this->Date . '</span>' . PHP_EOL;
        $HTML .= '<strong>' . $this->Summary . '</strong>' . PHP_EOL;
        $HTML .= '<div>' . PHP_EOL;
        $HTML .= $this->Content . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;
        
        return $HTML;
    }

}
