<commit_before>#!/usr/bin/env php
<?php

include_once __DIR__ . '/../common.php';
use Gaia\Test\Tap;
use Gaia\DirectedGraph\Node;
use Gaia\DirectedGraph\Execution;
use Gaia\Container;

Tap::plan(9);

class ExecutionPath extends Execution {
    public $name;
    public $parent = null;
    public $children = array();
    public $isActive = TRUE;

    public function __construct($name, Node $node) {
      parent::__construct($node);
      $this->name = $name;
    }
    
    public function createChild($name) {
      $child = new self($name, $this->node);
      $child->parent = $this;
      $this->children[ $name ] = $child;
      return $child;
    }
    
    public function end() {
        $this->isActive = false;
    }
}


  
function fork_it( ExecutionPath $execution) {
    foreach( array_keys( $execution->node->transitions ) as $event) $execution->createChild($event);
    foreach( $execution->children as $child ) $child->event($child->name);
}



/** join node implementation.  aka and-merge */
class Join extends Node {
    
    public $parentReactivationEvent = null;

    /** a join must have exactly 1 leaving transition */
    public function add($event, $destination) {
        if (count($this->transitions) == 1) {
            throw new Exception("a join must have exactly 1 transition");
        }
        parent::add($event, $destination);
        $this->parentReactivationEvent = $event;
    }
    
    public function execute(ExecutionPath $execution) {
        // mark the execution path that arrives in this join as 'ended'
        $execution->end();
        $hasActiveSibling = false;
      
        // create child execution paths
        foreach($execution->parent->children as $sibling) {
            if (! $sibling->isActive) continue;
            $hasActiveSibling = true;
            break;
        }
      
        if (!$hasActiveSibling) {
            // reactivate parent 
            // the parent was waiting in the fork.
            // the parent will now resume execution starting 
            // from this join
            $execution->parent->node = $this;
            $execution->parent->event($this->parentReactivationEvent);
        }
    }
}






//           _bill_<commit_msg>fixing an interface in the test<commit_after>#!/usr/bin/env php
<?php

include_once __DIR__ . '/../common.php';
use Gaia\Test\Tap;
use Gaia\DirectedGraph\Node;
use Gaia\DirectedGraph\Execution;
use Gaia\Container;

Tap::plan(9);

class ExecutionPath extends Execution {
    public $name;
    public $parent = null;
    public $children = array();
    public $isActive = TRUE;

    public function __construct($name, Node $node) {
      parent::__construct($node);
      $this->name = $name;
    }
    
    public function createChild($name) {
      $child = new self($name, $this->node);
      $child->parent = $this;
      $this->children[ $name ] = $child;
      return $child;
    }
    
    public function end() {
        $this->isActive = false;
    }
}


  
function fork_it( ExecutionPath $execution) {
    foreach( array_keys( $execution->node->transitions ) as $event) $execution->createChild($event);
    foreach( $execution->children as $child ) $child->event($child->name);
}



/** join node implementation.  aka and-merge */
class Join extends Node {
    
    public $parentReactivationEvent = null;

    /** a join must have exactly 1 leaving transition */
    public function add($event, $destination) {
        if (count($this->transitions) == 1) {
            throw new Exception("a join must have exactly 1 transition");
        }
        parent::add($event, $destination);
        $this->parentReactivationEvent = $event;
    }
    
    public function execute(Execution $execution) {
        if( ! $execution instanceof ExecutionPath ) throw new Exception('invalid execution path');
        // mark the execution path that arrives in this join as 'ended'
        $execution->end();
        $hasActiveSibling = false;
      
        // create child execution paths
        foreach($execution->parent->children as $sibling) {
            if (! $sibling->isActive) continue;
            $hasActiveSibling = true;
            break;
        }
      
        if (!$hasActiveSibling) {
            // reactivate parent 
            // the parent was waiting in the fork.
            // the parent will now resume execution starting 
            // from this join
            $execution->parent->node = $this;
            $execution->parent->event($this->parentReactivationEvent);
        }
    }
}






//           _bill_
{'fraction_non_alphanumeric': 0.12376779846659365, 'fraction_numerical': 0.0017524644030668128, 'mean_word_length': 2.315904139433551, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6334188', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1267, 'n_words': 349}