<commit_before><?php

include_once 'json_helper.php';

function fetch_categories() {
  return read_json('db/categories/categories.json');
}

function fetch_category_by_id($id) {
  $categories = fetch_categories();
  if ($categories == null) return null;
  return $categories[$id - 1]; # adjust for zero indexing
}

?><commit_msg>Use isset on categories check.<commit_after><?php

include_once 'json_helper.php';

function fetch_categories() {
  return read_json('db/categories/categories.json');
}

function fetch_category_by_id($id) {
  $categories = fetch_categories();

  if (!isset($categories)) return null;

  return $categories[$id - 1]; # adjust for zero indexing
}

?>
{'fraction_non_alphanumeric': 0.13884785819793205, 'fraction_numerical': 0.0029542097488921715, 'mean_word_length': 5.647058823529412, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1658235', 'n_tokens_mistral': 211, 'n_tokens_neox': 207, 'n_words': 49}