Adds new convenience methods
In my Bedrock projects I typically extend the Config class with some simple static methods which I have found to have broad utility. It is the aim of this PR to have them integrated into the core Config class.
I think that they are a good fit for inclusion here as they promote readability while also not over-complicating or obscuring implementation details (a central tenant of the Bedrock project.)
Further I am happy to submit a PR to the Bedrock repo taking advantage of the features included here, should there be interest. Or, it could just be left to be adopted incrementally.
Note that I have not updated the test suite. Personally I think adding @covers annotations to the existing methods would be sufficient, since the new methods are simply wrapping existing methods.
Examples of the syntax this PR enables
/**
* Configure auth keys and salts.
*/
Config::defineSet([
'AUTH_KEY' => env('AUTH_KEY'),
'AUTH_SALT' => env('AUTH_SALT'),
'LOGGED_IN_KEY' => env('LOGGED_IN_KEY'),
'LOGGED_IN_SALT' => env('LOGGED_IN_SALT'),
'NONCE_KEY' => env('NONCE_KEY'),
'NONCE_SALT' => env('NONCE_SALT'),
'SECURE_AUTH_KEY' => env('SECURE_AUTH_KEY'),
'SECURE_AUTH_SALT' => env('SECURE_AUTH_SALT'),
]);
if (Config::containsKey('DISPLAY_ERRORS')) {
ini_set('display_errors', Config::get('DISPLAY_ERRORS'));
}
if (Config::containsKeys(['SENTRY_DSN', 'WP_ENV']) &&
! Config::is('WP_ENV', 'development')) {
\Sentry\init([
'dsn' => Config::get('SENTRY_DSN'),
'environment' => Config::get('WP_ENV'),
'release' => Config::get('GIT_SHA'),
'error_types' => E_ALL & ~E_NOTICE & ~E_DEPRECATED,
]);
}
Pull Request Test Coverage Report for Build 64
- 0 of 7 (0.0%) changed or added relevant lines in 1 file are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage decreased (-29.2%) to 70.833%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| src/Config.php | 0 | 7 | 0.0% |
| <!-- | Total: | 0 | 7 |
| Totals | |
|---|---|
| Change from base Build 61: | -29.2% |
| Covered Lines: | 17 |
| Relevant Lines: | 24 |