<commit_before><?php

/**
 * @author <NAME> <<EMAIL>>
 */

namespace FTrace\Utils\Code;

use FTrace\Utils\Code\Unit;
use FTrace\Utils\Code\Call;
use FTrace\Utils\Code\Block;
use FTrace\Utils\Trace;

class Code {

    /**
     * @var int
     */
    private $_currentBlockPointer;

    /**
     * @var int
     */
    private $_depth;

    /**
     * @var Block[]
     */
    private $_blocks;

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

    /**
     * @param Trace $obTrace
     */
    public function pushCode (Trace $obTrace) {
        $unit = new Unit($obTrace);

        if ($this->_firstBlock() || $this->_noOpenBlocks($unit)) {
            $this->_initBlock($unit);
        } else {
            $this->_pushToCurrentBlock($unit);
        }
    }

    /**
     * @return Block[]
     */
    public function getBlocks () {
        return $this->_blocks;
    }

    /**
     * @param Unit $unit
     */
    private function _pushToCurrentBlock (Unit $unit) {
        $this->_getCurrentBlock()->addUnit($unit);
    }

    /**
     * @param Unit $unit
     */
    private function _initBlock (Unit $unit) {
        if ($this->_firstBlock()) {
            $this->_depth = $unit->getDepth();
        }

        if ($this->_depth > $unit->getDepth()) {
            return; // don't trace higher code levels
        }

        $block = new Block($unit, array(), $unit->getDepth());
        $this->_addBlock($block);
    }

    /**
     * @param Block $block
     */
    private function _addBlock (Block $block) {
        $this->_blocks[] = $block;
        $this->_stackPointerInc();
    }

    /**
     * @param Unit $unit
     * @return bool
     */
    private function _noOpenBlocks (Unit $unit) {
        $openBlocks = $this->_getOpenBlocks($unit);
        if (count($openBlocks) === 0) {
            return true;
        }
        return false;
    }<commit_msg>Code blocks are a live<commit_after><?php

/**
 * @author <NAME> <<EMAIL>>
 */

namespace FTrace\Utils\Code;

use FTrace\Utils\Code\Unit;
use FTrace\Utils\Code\Call;
use FTrace\Utils\Code\Block;
use FTrace\Utils\Trace;

class Code {

    /**
     * @var int
     */
    private $_currentBlockPointer;

    /**
     * @var int
     */
    private $_depth;

    /**
     * @var Block[]
     */
    private $_blocks;

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

    /**
     * @param Trace $obTrace
     */
    public function pushCode (Trace $obTrace) {
        $unit = new Unit($obTrace);

        if ($this->_firstBlock() || $this->_noOpenBlocks($unit)) {
            $this->_initBlock($unit);
        } else {
            $this->_pushToCurrentBlock($unit);
        }
    }

    /**
     * @return Block[]
     */
    public function getBlocks () {
        return $this->_blocks;
    }

    /**
     * @param Unit $unit
     */
    private function _pushToCurrentBlock (Unit $unit) {
        $this->_getCurrentBlock()->addUnit($unit);
    }

    /**
     * @param Unit $unit
     */
    private function _initBlock (Unit $unit) {
        if ($this->_firstBlock()) {
            $this->_depth = $unit->getDepth();
        }

        if ($this->_depth > $unit->getDepth()) {
            return; // don't trace higher code levels
        }

        $block = new Block($unit, array(), $this->_depth);
        $this->_addBlock($block);
    }

    /**
     * @param Block $block
     */
    private function _addBlock (Block $block) {
        $this->_blocks[] = $block;
        $this->_stackPointerInc();
    }

    /**
     * @param Unit $unit
     * @return bool
     */
    private function _noOpenBlocks (Unit $unit) {
        $openBlocks = $this->_getOpenBlocks($unit);
        if (count($openBlocks) === 0) {
            return true;
        }
        return false;
    }
{'fraction_non_alphanumeric': 0.1592641261498029, 'fraction_numerical': 0.0005256241787122207, 'mean_word_length': 1.8171724648408587, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 47, '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': '7212999', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1146, 'n_words': 250}