<commit_before><?php

namespace Bolt\Storage;

/**
 * Handles Object to DB naming adjustments.
 */
class NamingStrategy
{
    
    public $prefix = ''; 
    
    public function __construct($prefix = 'bolt_')
    {
        if ($prefix) {
            $this->prefix = $prefix;
        }
    }

    /**
     * Takes either a global or absolute class name and returns an underscored table name
     */
    public function classToTableName($className)
    {
        $className = $this->getRelativeClass($className);
        $className = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', $className)), '_');

        return $this->prefix.$className;
    }
    
    /**
     * Creates an automatic alias from a class name
     */
    public function classToAlias($className)
    {
        $className = $this->getRelativeClass($className);
        return strtolower(preg_replace('/[^A-Z]/', '', $className));
    }
    
    
    /**
     * Returns a class name with namespaces removed.
     */
    public function getRelativeClass($className)
    {
        if (strpos($className, '\\') !== false) {
            $className = substr($className, strrpos($className, '\\') + 1);
        }
        
        return $className;   
    }

    
}<commit_msg>simplify the alias naming strategy<commit_after><?php

namespace Bolt\Storage;

/**
 * Handles Object to DB naming adjustments.
 */
class NamingStrategy
{
    
    public $prefix = ''; 
    
    public function __construct($prefix = 'bolt_')
    {
        if ($prefix) {
            $this->prefix = $prefix;
        }
    }

    /**
     * Takes either a global or absolute class name and returns an underscored table name
     */
    public function classToTableName($className)
    {
        $className = $this->getRelativeClass($className);
        $className = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', $className)), '_');

        return $this->prefix.$className;
    }
    
    /**
     * Creates an automatic alias from a class name
     */
    public function classToAlias($className)
    {
        $className = $this->getRelativeClass($className);
        return ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', $className)), '_');
    }
    
    
    /**
     * Returns a class name with namespaces removed.
     */
    public function getRelativeClass($className)
    {
        if (strpos($className, '\\') !== false) {
            $className = substr($className, strrpos($className, '\\') + 1);
        }
        
        return $className;   
    }

    
}
{'fraction_non_alphanumeric': 0.14046955829685634, 'fraction_numerical': 0.0019896538002387586, 'mean_word_length': 2.1662468513853903, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '6176887', 'n_tokens_mistral': 733, 'n_tokens_neox': 714, 'n_words': 167}