misatotremor / case-bundle
Symfony Case Converter Bundle
Installs: 6 208
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 3
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.4 || ^8.0
- twig/twig: ^2.14 || ^3.0
Requires (Dev)
- symfony/config: ^5.4 || ^6.0 || ^7.0
- symfony/dependency-injection: ^5.4 || ^6.0 || ^7.0
- symfony/http-kernel: ^5.4 || ^6.0 || ^7.0
- symfony/phpunit-bridge: ^5.4 || ^6.0 || ^7.0
Conflicts
- twig/twig: <2.14.7 || >=3.0 <3.3.3
Replaces
README
Convert strings or strings in arrays to different case formats.
Supports: camelCase, PascalCase, Title Case, and underscore_case.
This is a fork of jdewits original code.
Installation
This bundle is listed on packagist.
Download the bundle
$ composer require misatotremor/case-bundle
Enable the bundle
<?php // config/bundles.php return [ // ... Avro\CaseBundle\AvroCaseBundle::class => ['all' => true], // ... ];
Configuration
Optional: Add this config
# config/packages/avro_case.yaml avro_case: use_twig: false #disable the twig extension (true by default)
Usage
<?php use Avro\CaseBundle\Util\CaseConverter; class SomeClass { private $caseConverter; /** * @param CaseConverter $caseConverter */ public function __construct(CaseConverter $caseConverter) { $this->caseConverter = $caseConverter; } /** * @param string $str */ public function foo(string $str) { $camelCaseFormat = $this->converter->toCamelCase($str); $pascalCaseFormat = $this->converter->toPascalCase($str); $titleCaseFormat = $this->converter->toTitleCase($str); $underscoreCaseFormat = $this->converter->toUnderscoreCase($str); } }
The following filters are also available if you use Twig
{{ var | camel }} {{ var | pascal }} {{ var | title }} {{ var | underscore }}