chrisharrison / case-converter
A factory wrapper around jawira/case-converter
Installs: 7 318
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.2
- jawira/case-converter: ^3.1
Requires (Dev)
- phpunit/phpunit: ^6.3
This package is auto-updated.
Last update: 2024-11-05 22:56:40 UTC
README
A factory wrapper around jawira/case-converter
Injectable
This library allows the functionality of the excellent jawira/case-converter
to be injected as a dependency into other classes.
final class SomethingThatNeedsToConvertCase
{
private $caseConverter;
private $defaultSuffix;
public function __construct(CaseConverter $caseConverter, string $defaultSuffix)
{
$this->caseConverter = $caseConverter;
$this->defaultSuffix = $defaultSuffix;
}
public function usesTheConverter(string $aStringFromSomethingElse): string
{
$this->caseConverter->from($aStringFromSomethingElse)->toCamel() . $this->defaultSuffix;
}
}
Testable/mockable
The library allows the case conversion dependency to be mocked so classes can be more easily tested.