<commit_before><?php
/**
 * PHPSpec
 *
 * LICENSE
 *
 * This file is subject to the GNU Lesser General Public License Version 3
 * that is bundled with this package in the file LICENSE.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/lgpl-3.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * @category   PHPSpec
 * @package    PHPSpec
 * @copyright  Copyright (c) 2007 <NAME>, <NAME>
 * @license    http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
 */

/**
 * @category   PHPSpec
 * @package    PHPSpec
 * @copyright  Copyright (c) 2007 <NAME>, <NAME>
 * @license    http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
 * @todo       Needs a suite of updated tests, esp. addressing output being traced out
 */
class PHPSpec_Runner_Result implements Countable
{

    protected $_examples = array();

    protected $_failCount = 0;

    protected $_passCount = 0;

    protected $_exceptionCount = 0;

    protected $_errorCount = 0;
    
    protected $_pendingCount = 0;

    protected $_specCount = 0;
    
    protected $_reporter = null;
    
    protected $_runtimeStart = 0;
    
    protected $_runtimeEnd = 0;

    public function execute(PHPSpec_Runner_Collection $collection)
    {
        $collection->execute($this);
    }

    public function addFailure(PHPSpec_Runner_Example $example)
    {
        $this->_examples[] = new PHPSpec_Runner_Example_Fail($example);
        $this->_failCount++;
        $this->_reporter->outputStatus('F');
    }

    public function addException(PHPSpec_Runner_Example $example, Exception $e)
    {
        $this->_examples[] = new PHPSpec_Runner_Example_Exception($example, $e);
        $this->_exceptionCount++;
        $this->_reporter->outputStatus('E');
    }

    public function addError(PHPSpec_Runner_Example $example, Exception $e)
    {
        $this->_examples[] = new PHPSpec_Runner_Example_Error($example, $e);
        $this->_errorCount++;
        $this->_reporter->outputStatus('E');
    }
    
    public function addPending(PHPSpec_Runner_Example $example, Exception $e)
    {
        $this->_examples[] = new PHPSpec_Runner_Example_Pending($example, $e);
        $this->_pendingCount++;
        $this->_reporter->outputStatus('P');
    }

    public function addPass(PHPSpec_Runner_Example $example)
    {
        $this->_examples[] = new PHPSpec_Runner_Example_Pass($example);
        $this->_passCount++;
        $this->_reporter->outputStatus('.');
    }

    /**
     * Get an array of Example types which contain the specific Example
     * objects to collate any other details needed for reporting or
     * even re-performance.
     * 
     * @todo Needs refactoring to remove these duplicate methods!
     * @param string $type The PHPSpec_Runner_Example type being declared
     * @return array Array of all examples of this specific type
     */
    public function getTypes($type)
    {
        $class = 'PHPSpec_Runner_Example_' . ucfirst($type);
        $types = array();
        foreach ($this->_examples as $example) {
            if ($example instanceof $class) {
                $types[] = $example;
            }
        }
        return $types;
    }
    
    public function setReporter(PHPSpec_Runner_Reporter $reporter)
    {
    	$this->_reporter = $reporter;
    }
    
<commit_msg>Fixed presentation bug - Exception instanceof checks were also capturing Error/Pending exceptions since they are subclasses of this same type<commit_after><?php
/**
 * PHPSpec
 *
 * LICENSE
 *
 * This file is subject to the GNU Lesser General Public License Version 3
 * that is bundled with this package in the file LICENSE.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/lgpl-3.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * @category   PHPSpec
 * @package    PHPSpec
 * @copyright  Copyright (c) 2007 <NAME>, <NAME>
 * @license    http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
 */

/**
 * @category   PHPSpec
 * @package    PHPSpec
 * @copyright  Copyright (c) 2007 <NAME>, <NAME>
 * @license    http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
 * @todo       Needs a suite of updated tests, esp. addressing output being traced out
 */
class PHPSpec_Runner_Result implements Countable
{

    protected $_examples = array();

    protected $_failCount = 0;

    protected $_passCount = 0;

    protected $_exceptionCount = 0;

    protected $_errorCount = 0;
    
    protected $_pendingCount = 0;

    protected $_specCount = 0;
    
    protected $_reporter = null;
    
    protected $_runtimeStart = 0;
    
    protected $_runtimeEnd = 0;

    public function execute(PHPSpec_Runner_Collection $collection)
    {
        $collection->execute($this);
    }

    public function addFailure(PHPSpec_Runner_Example $example)
    {
        $this->_examples[] = new PHPSpec_Runner_Example_Fail($example);
        $this->_failCount++;
        $this->_reporter->outputStatus('F');
    }

    public function addException(PHPSpec_Runner_Example $example, Exception $e)
    {
        $this->_examples[] = new PHPSpec_Runner_Example_Exception($example, $e);
        $this->_exceptionCount++;
        $this->_reporter->outputStatus('E');
    }

    public function addError(PHPSpec_Runner_Example $example, Exception $e)
    {
        $this->_examples[] = new PHPSpec_Runner_Example_Error($example, $e);
        $this->_errorCount++;
        $this->_reporter->outputStatus('E');
    }
    
    public function addPending(PHPSpec_Runner_Example $example, Exception $e)
    {
        $this->_examples[] = new PHPSpec_Runner_Example_Pending($example, $e);
        $this->_pendingCount++;
        $this->_reporter->outputStatus('P');
    }

    public function addPass(PHPSpec_Runner_Example $example)
    {
        $this->_examples[] = new PHPSpec_Runner_Example_Pass($example);
        $this->_passCount++;
        $this->_reporter->outputStatus('.');
    }

    /**
     * Get an array of Example types which contain the specific Example
     * objects to collate any other details needed for reporting or
     * even re-performance.
     * 
     * @todo Needs refactoring to remove these duplicate methods!
     * @param string $type The PHPSpec_Runner_Example type being declared
     * @return array Array of all examples of this specific type
     */
    public function getTypes($type)
    {
        $class = 'PHPSpec_Runner_Example_' . ucfirst($type);
        $types = array();
        foreach ($this->_examples as $example) {
            if ($class == 'PHPSpec_Runner_Example_Exception') {
                if ($example instanceof $class
                    && !$example instanceof PHPSpec_Runner_Example_Error
                    && !$example instanceof PHPSpec_Runner_Example_Pending) {
                    $types[] = $example;
                }
            } elseif ($example instanceof $class) {
                $types[] = $example;
            }
            
            
        }
        return $types;
    }
    
    public function setReporter(PHPSpec_Runner_Reporter $reporter)
    {
    	$this->_reporter = $reporter;
    }
    

{'fraction_non_alphanumeric': 0.10627570651452832, 'fraction_numerical': 0.006633939233116624, 'mean_word_length': 2.7409429280397024, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '900549', 'n_tokens_mistral': 2163, 'n_tokens_neox': 2122, 'n_words': 611}