bartoszbartniczak/naming-convention-converter

This library allows to apply different naming conventions.

1.1.1 2017-02-19 20:33 UTC

This package is auto-updated.

Last update: 2024-11-13 10:31:30 UTC


README

This library allows to apply different naming conventions.

Usage

camelCase to underscore

<?php

use BartoszBartniczak\NamingConventionConverter\CamelCaseToUnderscoreConverter;
use BartoszBartniczak\NamingConventionConverter\UnderscoreToCamelCaseConverter;

$camelCaseToUnderscoreConverter = new CamelCaseToUnderscoreConverter();
$camelCaseToUnderscoreConverter->convert('camelCaseToUnderscoreConverter');
// camelCaseToUnderscoreConverter -> camel_case_to_underscore_converter

$underscoreToCamelCaseConverter = new UnderscoreToCamelCaseConverter();
$underscoreToCamelCaseConverter->convert('camel_case_to_underscore_converter');
// camel_case_to_underscore_converter -> camelCaseToUnderscoreConverter

CamelCase to underscore

<?php

use BartoszBartniczak\NamingConventionConverter\PascalCaseToUnderscoreConverter;
use BartoszBartniczak\NamingConventionConverter\UnderscoreToPascalCaseConverter;

$pascalCaseToUnderscoreConverter = new PascalCaseToUnderscoreConverter();
$pascalCaseToUnderscoreConverter->convert('PascalCaseToUnderscoreConverter');
// PascalCaseToUnderscoreConverter -> pascal_case_to_underscore_converter

$underscoreToPascalCaseConverter = new UnderscoreToPascalCaseConverter();
$underscoreToPascalCaseConverter->convert('pascal_case_to_underscore_converter');
// pascal_case_to_underscore_converter -> PascalCaseToUnderscoreConverter

Lazy converter

Lazy converter does nothing. You can use it as plug, when you don't want to change nothing.

<?php

use BartoszBartniczak\NamingConventionConverter\LazyConverter;

$lazyConverter = new LazyConverter();
$lazyConverter->convert('i don\'t want to do anything');
// i don't want to do anything -> i don't want to do anything