<commit_before><?php

class HtmlHelper extends Helper {

  private $endTags = array('<ul>' => '</ul>', '<li>' => '</li>');

  public function getEndTag($tag) {
    if (!isset($this->endTags[$tag])) {
      $matches = array();
      preg_match('/<\s*([a-zA-Z0-9]+)/', $tag, $matches);
      $this->endTags[$tag] = '</' . $matches[1] . '>';
    }
    return $this->endTags[$tag];
  }

  private function addAttributes($options) {
    $html = '';
    if (isset($options['data'])) {
      $data = $options['data'];
      unset($options['data']);
      foreach ($data as $key => $value) {
        $html .= ' data-' . $key . '="' . h($value) . '"';
      }
    }
    foreach ($options as $attribute => $value) {
      $html .= ' ' . $attribute . '="' . h($value) . '"';
    }
    return $html;
  }

  public function link($label, $route = null, $attributes = array()) {
    $url = $this->m
      ->Routing
      ->getLink($route);
    return '<a href="' . h($url) . '"' . $this->addAttributes($attributes)
        . '>' . $label . '</a>';
  }

  public function nestedList($list, $listTag = '<ul>', $itemTag = '<li>') {<commit_msg>HtmlHelper returns false for invalid links instead<commit_after><?php

class HtmlHelper extends Helper {

  private $endTags = array('<ul>' => '</ul>', '<li>' => '</li>');

  public function getEndTag($tag) {
    if (!isset($this->endTags[$tag])) {
      $matches = array();
      preg_match('/<\s*([a-zA-Z0-9]+)/', $tag, $matches);
      $this->endTags[$tag] = '</' . $matches[1] . '>';
    }
    return $this->endTags[$tag];
  }

  private function addAttributes($options) {
    $html = '';
    if (isset($options['data'])) {
      $data = $options['data'];
      unset($options['data']);
      foreach ($data as $key => $value) {
        $html .= ' data-' . $key . '="' . h($value) . '"';
      }
    }
    foreach ($options as $attribute => $value) {
      $html .= ' ' . $attribute . '="' . h($value) . '"';
    }
    return $html;
  }

  public function link($label, $route = null, $attributes = array()) {
    try {
      $url = $this->m
        ->Routing
        ->getLink($route);
    }
    catch (InvalidRouteException $e) {
      return false;
    }
    return '<a href="' . h($url) . '"' . $this->addAttributes($attributes)
        . '>' . $label . '</a>';
  }

  public function nestedList($list, $listTag = '<ul>', $itemTag = '<li>') {
{'fraction_non_alphanumeric': 0.2417860151642797, 'fraction_numerical': 0.002527379949452401, 'mean_word_length': 2.5185185185185186, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 43, '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': '3494206', 'n_tokens_mistral': 806, 'n_tokens_neox': 797, 'n_words': 168}