<?php

namespace Signteer\Web\Common\Ui\Renderer;

use Plainwork\Http\Request;
use Plainwork\Ui\Html;
use Signteer\Core\Model\Volunteer;

final class VolunteerRenderer
{
    public function __invoke(Volunteer $m, Request $request)
    {
        $path = $request->getPath();

        if ('admin/' === substr($path, 0, strlen('admin/'))) {
            $html = new Html();
            $ret = $html->inlineList();
            $ret->add($html->el('b', $m->getTitle()));

            $email = $m->getEmail();
            if (strlen($email)) {
                $ret->add($email);
            }

            $phone = $m->getPhone();
            if (strlen($phone)) {
                $ret->add($phone);
            }
        } else {
            $ret = $m->getTitle();
        }

        return $ret;
    }
}
