<commit_before><?php

namespace Event\View\Helper;

/**
 * Description of HtmlTable
 *
 * @author <NAME> <<EMAIL>>
 */
class HtmlTable extends \Zend\View\Helper\AbstractHtmlElement implements \Event\View\Helper\HtmlTableInterface
{

    public function __invoke(\Zend\Paginator\Paginator $items, $class = 'table-striped')
    {
        $table = '';
        if (!empty($items)) {
            $table .= $this->renderHeader($items->getItem(0));
            $table .= '<tbody>';
            foreach ($items as $row) {
                $table .= $this->renderRow($row);
            }
            $table .= '</tbody>';
        } else {
            $table = '<tr><td>Keine Daten gefunden.</td></tr>';
        }

        return '<table class="table ' . $class . '">' . $table . '</table>';
    }

    /**
     *
     * @param type $item
     * @return string
     */
    public function renderRow($item)
    {
        $row = '';
        if (is_array($item)) {
            foreach ($item as $column => $value) {
                $row .= '<td>' . $value . '</td>';
            }
        } elseif ($item instanceof \Event\Entity\EventInterface) {
            $row .= '<td>' . $item->getId() . '</td>';
            $row .= '<td>' . $item->getTitle() . '</td>';
            $row .= '<td>' . $item->getEventDate('string') . '</td>';
            $row .= '<td class="controls">
                        <div class="btn-group">
                            <a class="btn" href="' . $this->getView()->url('events/action', array('action' => 'show', 'id' => $item->getId())) . '"><i class="icon-info-sign"></i></a>
                            <a class="btn" href="' . $this->getView()->url('events/action', array('action' => 'edit', 'id' => $item->getId())) . '"><i class="icon-edit"></i></a>
                            <a class="btn btn-danger" href="' . $this->getView()->url('events/action', array('action' => 'delete', 'id' => $item->getId())) . '"><i class="icon-trash"></i></a>
                        </div>
                    </td>';
        } elseif ($item instanceof \Event\Entity\EventsGuests) {
            $row .= '<td>' . $item->getGuest()->getId() . '</td>';
            $row .= '<td>' . $item->getGuest()->getPrename() . ' ' . $item->getGuest()->getLastname() . '</td>';
            $row .= '<td>' . $item->getGuest()->getEmail() . '</td>';
            $row .= '<td>' . $this->getView()->confirmation($item->getConfirmation()) . '</td>';
            $row .= '<td class="controls">
                        <div class="btn-group">
                            <a class="btn" href="' . $this->getView()->url('events/action', array('action' => 'show', 'id' => $item->getId())) . '"><i class="icon-info-sign"></i></a>
                            <a class="btn" href="' . $this->getView()->url('events/action', array('action' => 'edit', 'id' => $item->getId())) . '"><i class="icon-envelope"></i></a>
                        </div>
                    </td>';
        }

        return '<tr>' . $row . '</tr>';
    }<commit_msg>[BUGFIX] If no items are availabel <commit_after><?php

namespace Event\View\Helper;

/**
 * Description of HtmlTable
 *
 * @author <NAME> <<EMAIL>>
 */
class HtmlTable extends \Zend\View\Helper\AbstractHtmlElement implements \Event\View\Helper\HtmlTableInterface
{

    public function __invoke(\Zend\Paginator\Paginator $items, $class = 'table-striped')
    {
        $table = '';

        if (!empty($items) && (0 < $items->getTotalItemCount())) {
            $table .= $this->renderHeader($items->getItem(0));
            $table .= '<tbody>';
            foreach ($items as $row) {
                $table .= $this->renderRow($row);
            }
            $table .= '</tbody>';
        } else {
            $table = '<tr><td>Keine Daten gefunden.</td></tr>';
        }

        return '<table class="table ' . $class . '">' . $table . '</table>';
    }

    /**
     *
     * @param type $item
     * @return string
     */
    public function renderRow($item)
    {
        $row = '';
        if (is_array($item)) {
            foreach ($item as $column => $value) {
                $row .= '<td>' . $value . '</td>';
            }
        } elseif ($item instanceof \Event\Entity\EventInterface) {
            $row .= '<td>' . $item->getId() . '</td>';
            $row .= '<td>' . $item->getTitle() . '</td>';
            $row .= '<td>' . $item->getEventDate('string') . '</td>';
            $row .= '<td class="controls">
                        <div class="btn-group">
                            <a class="btn" href="' . $this->getView()->url('events/action', array('action' => 'show', 'id' => $item->getId())) . '"><i class="icon-info-sign"></i></a>
                            <a class="btn" href="' . $this->getView()->url('events/action', array('action' => 'edit', 'id' => $item->getId())) . '"><i class="icon-edit"></i></a>
                            <a class="btn btn-danger" href="' . $this->getView()->url('events/action', array('action' => 'delete', 'id' => $item->getId())) . '"><i class="icon-trash"></i></a>
                        </div>
                    </td>';
        } elseif ($item instanceof \Event\Entity\EventsGuests) {
            $row .= '<td>' . $item->getGuest()->getId() . '</td>';
            $row .= '<td>' . $item->getGuest()->getPrename() . ' ' . $item->getGuest()->getLastname() . '</td>';
            $row .= '<td>' . $item->getGuest()->getEmail() . '</td>';
            $row .= '<td>' . $this->getView()->confirmation($item->getConfirmation()) . '</td>';
            $row .= '<td class="controls">
                        <div class="btn-group">
                        </div>
                    </td>';
        }

        return '<tr>' . $row . '</tr>';
    }
{'fraction_non_alphanumeric': 0.2366812227074236, 'fraction_numerical': 0.0005240174672489083, 'mean_word_length': 1.779611650485437, 'pattern_counts': {'":': 0, '<': 112, '<?xml version=': 0, '>': 186, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '247222', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1693, 'n_words': 334}