<commit_before><?php
/**
 * The string wrapper class. 
 *
 * @package    phpMyFAQ
 * @subpackage PMF_String
 * @license    MPL
 * @author     <NAME> <<EMAIL>>
 * @since      2009-04-06
 * @copyright  2004-2009 phpMyFAQ Team
 * @version    SVN: $Id: Category.php,v 1.56 2008-01-26 01:02:56 thorstenr Exp $
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

/**
 * PMF_String
 * 
 * The class uses mbstring extension if available. It's strongly recommended
 * to use and extend this class instead of using direct string functions. Doing so
 * you garantee your code is upwards compatible with UTF-8 improvements.
 *
 * @package    phpMyFAQ
 * @subpackage PMF_String
 * @license    MPL
 * @author     <NAME> <<EMAIL>>
 * @since      2009-04-06
 * @copyright  2004-2009 phpMyFAQ Team
 * @version    SVN: $Id: String.php,v 1.56 2008-01-26 01:02:56 thorstenr Exp $
 */
class PMF_String
{
    private static $instance;
    
    private final function __construct()
    {
        /**
         * just blocking
         */
    }
    
    /** 
     * Initalize myself
     * @return void
     */
    public static function init($encoding = null)
    {
        if(!self::$instance) {
            $cwd = dirname(__FILE__);
            if(extension_loaded('mbstring')) {
                self::$instance = PMF_String_Mbstring::getInstance($encoding);
            } else {
                self::$instance = PMF_String_Basic::getInstance($encoding);
            }
        }
    }
    
    
    /**
     * Get current encoding
     * @return string
     */
    public static function getEncoding()
    {
    	return self::$instance->getEncoding();
    }
    
    
    /**
     * Get string character count
     * 
     * @param string $str
     * 
     * @return int
     */
    public static function strlen($str)<commit_msg>no need to calculate cwd since there is autoloader<commit_after><?php
/**
 * The string wrapper class. 
 *
 * @package    phpMyFAQ
 * @subpackage PMF_String
 * @license    MPL
 * @author     <NAME> <<EMAIL>>
 * @since      2009-04-06
 * @copyright  2004-2009 phpMyFAQ Team
 * @version    SVN: $Id: Category.php,v 1.56 2008-01-26 01:02:56 thorstenr Exp $
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

/**
 * PMF_String
 * 
 * The class uses mbstring extension if available. It's strongly recommended
 * to use and extend this class instead of using direct string functions. Doing so
 * you garantee your code is upwards compatible with UTF-8 improvements.
 *
 * @package    phpMyFAQ
 * @subpackage PMF_String
 * @license    MPL
 * @author     <NAME> <<EMAIL>>
 * @since      2009-04-06
 * @copyright  2004-2009 phpMyFAQ Team
 * @version    SVN: $Id: String.php,v 1.56 2008-01-26 01:02:56 thorstenr Exp $
 */
class PMF_String
{
    private static $instance;
    
    private final function __construct()
    {
        /**
         * just blocking
         */
    }
    
    /** 
     * Initalize myself
     * @return void
     */
    public static function init($encoding = null)
    {
        if(!self::$instance) {
            if(extension_loaded('mbstring')) {
                self::$instance = PMF_String_Mbstring::getInstance($encoding);
            } else {
                self::$instance = PMF_String_Basic::getInstance($encoding);
            }
        }
    }
    
    
    /**
     * Get current encoding
     * @return string
     */
    public static function getEncoding()
    {
    	return self::$instance->getEncoding();
    }
    
    
    /**
     * Get string character count
     * 
     * @param string $str
     * 
     * @return int
     */
    public static function strlen($str)
{'fraction_non_alphanumeric': 0.10255839822024472, 'fraction_numerical': 0.030700778642936598, 'mean_word_length': 2.3254437869822486, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '7451522', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1283, 'n_words': 433}