<?php

namespace Eater\Glim\Handler;

use Eater\Glim\Service\GitHub;

class Home extends Session
{
    protected $shouldHaveUser = false;

    function handle()
    {
        /** @var GitHub $github */
        $github = $this->get('github');

        /** @var string $repo */
        $repo = $this->get('github-repo');

        /** @var string $author */
        $author = $this->get('author');

        $info = $github->getRepoInfo();

        if ($info !== false) {
            $author = $info['owner']['login'];
        }

        return $this->render("home.html.twig", [
            'author' => $author,
            'contributors' => $github->getContributors(),
            'githubRepo' => $repo
        ]);
    }
}