Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camel case keys in response #25

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- **BREAKING**: Require Laravel 11.
- **BREAKING**: Camel case keys in response.

## [0.5.2] - 2023-12-29
### Added
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The endpoint will return data in JSON.
"environment": {},
"cache": {},
"drivers": {},
"butler_health": {
"butlerHealth": {
"version": "0.1"
},
},
Expand Down Expand Up @@ -81,7 +81,7 @@ Extend `Butler\Health\Check` and add it to `butler.health.checks`, done.
You can push additional "about" information.

```php
Butler\Health\Repository::add('environment', ['operating_system' => php_uname('s')]);
Butler\Health\Repository::add('environment', ['operatingSystem' => php_uname('s')]);

Butler\Health\Repository::add('environment', fn () => ['time' => time()]);
```
Expand All @@ -90,12 +90,12 @@ Butler\Health\Repository::add('environment', fn () => ['time' => time()]);
{
"about": {
"environment": {
"operating_system": "Linux",
"operatingSystem": "Linux",
"time": 1678100209
},
"cache": {},
"drivers": {},
"butler_health": {},
"butlerHealth": {},
},
"checks": []
}
Expand Down
14 changes: 7 additions & 7 deletions src/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ private function gatherAbout(): array

$data = [
'environment' => [
'application_name' => config('app.name'),
'laravel_version' => $laravel->version(),
'php_version' => phpversion(),
'composer_version' => $laravel->make(Composer::class)->getVersion(),
'applicationName' => config('app.name'),
'laravelVersion' => $laravel->version(),
'phpVersion' => phpversion(),
'composerVersion' => $laravel->make(Composer::class)->getVersion(),
'environment' => $laravel->environment(),
'debug_mode' => config('app.debug') ? true : false,
'debugMode' => config('app.debug') ? true : false,
'url' => str(config('app.url'))->replace(['http://', 'https://'], '')->toString(),
'timezone' => config('app.timezone'),
],
Expand All @@ -49,12 +49,12 @@ private function gatherAbout(): array
'queue' => config('queue.default'),
'session' => config('session.driver'),
],
'butler_health' => [
'butlerHealth' => [
'version' => ltrim(InstalledVersions::getPrettyVersion('glesys/butler-health'), 'v'),
],
'request' => [
'ip' => request()->ip(),
'user_agent' => request()->userAgent(),
'userAgent' => request()->userAgent(),
],
];

Expand Down
14 changes: 7 additions & 7 deletions tests/RepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public function test_invoke_returns_correct_default_information()
->has('about', fn (AssertableJson $json) => $json
->has('environment', fn (AssertableJson $json) => $json
->hasAll(
'application_name',
'laravel_version',
'php_version',
'composer_version',
'applicationName',
'laravelVersion',
'phpVersion',
'composerVersion',
'environment',
'debug_mode',
'debugMode',
'url',
)
->where('timezone', config('app.timezone'))
Expand All @@ -40,9 +40,9 @@ public function test_invoke_returns_correct_default_information()
'session',
)
)
->has('butler_health.version')
->has('butlerHealth.version')
->has('request', fn (AssertableJson $json) => $json
->hasAll('ip', 'user_agent')
->hasAll('ip', 'userAgent')
)
)
->where('checks', [
Expand Down