<commit_before><?php
/**
 * @version 	$Id$
 * @package		Koowa_Loader
 * @subpackage 	Adapter
 * @copyright	Copyright (C) 2007 - 2012 <NAME>. All rights reserved.
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 */

/**
 * Loader Adapter for the Koowa framework
 *
 * @author		<NAME> <<EMAIL>>
 * @package     Koowa_Loader
 * @subpackage 	Adapter
 * @uses 		Koowa
 */
class KLoaderAdapterKoowa extends KLoaderAdapterAbstract
{
	/**
	 * The adapter type
	 *
	 * @var string
	 */
	protected $_type = 'koowa';

	/**
	 * The class prefix
	 *
	 * @var string
	 */
	protected $_prefix = 'K';

	/**
	 * Get the path based on a class name
	 *
	 * @param  string		  	The class name
	 * @return string|false		Returns the path on success FALSE on failure
	 */
	public function findPath($classname, $basepath = null)
	{
		$path     = false;

		$word  = preg_replace('/(?<=\\w)([A-Z])/', ' \\1',  $classname);
		$parts = explode(' ', $word);

		// If class start with a 'K' it is a Koowa framework class and we handle it
		if(array_shift($parts) == $this->_prefix)
		{
		    $path = strtolower(implode('/', $parts));

			if(count($parts) == 1) {
				$path = $path.'/'.$path;
			}<commit_msg>re #281 : Added special loading rules for exception. Exceptions classes cannot be deep nested. Classname is transformed into lower case to always load the exception class from the /exception/ folder.<commit_after><?php
/**
 * @version 	$Id$
 * @package		Koowa_Loader
 * @subpackage 	Adapter
 * @copyright	Copyright (C) 2007 - 2012 <NAME>. All rights reserved.
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 */

/**
 * Loader Adapter for the Koowa framework
 *
 * @author		<NAME> <<EMAIL>>
 * @package     Koowa_Loader
 * @subpackage 	Adapter
 * @uses 		Koowa
 */
class KLoaderAdapterKoowa extends KLoaderAdapterAbstract
{
	/**
	 * The adapter type
	 *
	 * @var string
	 */
	protected $_type = 'koowa';

	/**
	 * The class prefix
	 *
	 * @var string
	 */
	protected $_prefix = 'K';

	/**
	 * Get the path based on a class name
	 *
	 * @param  string		  	The class name
	 * @return string|false		Returns the path on success FALSE on failure
	 */
	public function findPath($classname, $basepath = null)
	{
		$path = false;

        //Exceptions classes cannot be deep nested. Transform classname to lower
        //case to always load the exception class from the /exception/ folder.
        if($pos = strpos($classname, 'Exception'))
        {
            $filename  = substr($classname, $pos + strlen('Exception'));
            $classname = str_replace($filename, ucfirst(strtolower($filename)), $classname);
        }

		$word  = preg_replace('/(?<=\\w)([A-Z])/', ' \\1',  $classname);
		$parts = explode(' ', $word);

		// If class start with a 'K' it is a Koowa framework class and we handle it
		if(array_shift($parts) == $this->_prefix)
		{
		    $path = strtolower(implode('/', $parts));

			if(count($parts) == 1) {
				$path = $path.'/'.$path;
			}
{'fraction_non_alphanumeric': 0.14922349763673193, 'fraction_numerical': 0.008440243079000676, 'mean_word_length': 2.940159574468085, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7382317', 'n_tokens_mistral': 1054, 'n_tokens_neox': 954, 'n_words': 297}