PHP code example of lexide / k-switch
1. Go to this page and download the library: Download lexide/k-switch 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/ */
lexide / k-switch example snippets
class Converter {
use Lexide\KSwitch\NameConverterTrait;
public function convertStudly($string)
{
return $this->toStudlyCaps($string);
}
public function convertCamel($string)
{
return $this->toCamelCase($string);
}
public function convertSnake($string)
{
return $this->toSplitCase($string);
}
}
$converter = new Converter();
$converter->convertStudly("aCamelCaseName"); // ACamelCaseName
$studly = $converter->convertStudly("a_snake_case_name"); // returns "ASnakeCaseName"
$converter->convertSnake($studly); // back to "a_snake_case_name"