<commit_before><?php
namespace LazyRecord;

class TransactionManager
{
    public $conn;

    /**
     * @var int active transaction counter.
     */
    public $transactionCounter = 0;

    public function __construct($conn)
    {
        $this->conn = $conn;
    }

    public function begin() {
        if ($this->conn->beginTransaction() ) {
            $this->transactionCounter++;
        }
    }

    public function rollback() {
        $this->conn->rollback();
        $this->transactionCounter--;
    }

    public function commit() {
        $this->conn->commit();
        $this->transactionCounter--;
    }

    public function hasActive() {
        return $this->transactionCounter > 0;
    }
}



<commit_msg>check txn counter<commit_after><?php
namespace LazyRecord;

class TransactionManager
{
    public $conn;

    /**
     * @var int active transaction counter.
     */
    public $transactionCounter = 0;

    public function __construct($conn)
    {
        $this->conn = $conn;
    }

    public function begin() {
        if ($this->conn->beginTransaction() ) {
            $this->transactionCounter++;
        }
    }

    public function rollback() {
        if ( --$this->transactionCounter >= 0 ) {
            $this->conn->rollback();
        }
    }

    public function commit() {
        if ( --$this->transactionCounter >= 0 ) {
            $this->conn->commit();
        }
    }

    public function hasActive() {
        return $this->transactionCounter > 0;
    }
}




{'fraction_non_alphanumeric': 0.13696808510638298, 'fraction_numerical': 0.003989361702127659, 'mean_word_length': 1.9684418145956608, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '2961976', 'n_tokens_mistral': 432, 'n_tokens_neox': 410, 'n_words': 90}