<commit_before><?php

namespace SDO\Database;

use PDO;

trait DatabaseTrait {
  protected $db;

  public function setDatabase(PDO $db) {
    $this->db = $db;
  }
}
<commit_msg>Database trait now contains an accessor<commit_after><?php

namespace SDO\Database;

/**
 * Get/Set PDO database objects
 */
trait DatabaseTrait
{
  /**
   * @var \PDO
   */
  protected $db;

  /**
   * Sets the current database
   * 
   * @param \PDO $db
   */
  public function setDatabase(\PDO $db) {
    $this->db = $db;
  }

  /**
   * Gets the current database
   * 
   * @throws \LogicException if no database has been set
   * @return \PDO
   */
  public function getDatabase() {
    if (!$this->db) {
      throw new \LogicException('No database set, you must set a PDO instance via setDatabase() first');
    }
    return $this->db;
  }
}

{'fraction_non_alphanumeric': 0.13317191283292978, 'fraction_numerical': 0.0, 'mean_word_length': 2.643171806167401, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6621204', 'n_tokens_mistral': 286, 'n_tokens_neox': 285, 'n_words': 81}