https://github.com/chrisharrison/case-converter
A factory wrapper around jawira/case-converter
https://github.com/chrisharrison/case-converter
Last synced: 8 months ago
JSON representation
A factory wrapper around jawira/case-converter
- Host: GitHub
- URL: https://github.com/chrisharrison/case-converter
- Owner: chrisharrison
- Created: 2019-07-30T08:58:15.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-05T10:40:41.000Z (almost 7 years ago)
- Last Synced: 2025-06-10T03:50:59.770Z (12 months ago)
- Language: PHP
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# case-converter
A factory wrapper around [jawira/case-converter](https://github.com/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.