PHP code example of intellex / naming-convention

1. Go to this page and download the library: Download intellex/naming-convention library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

intellex / naming-convention example snippets


use Intellex\NamingConvention\NamingConvention

# Validate
NamingConvention::CAMEL_CASE->validate('myVarName');  // true
NamingConvention::SNAKE_CASE->validate('Snake_Case'); // false

# Detect the convention
$varName =  NamingConvention::determineApplicableConvention('my_var_name');
$varName->convention // NamingConvention::SNAKE_CASE

# Convert
$newName = $varName->convertTo(NamingConvention::PASCAL_CASE);
$newName->name       // "MyVarName"