automattic / jetpack-constants
A wrapper for defining constants in a more testable way.
Installs: 2 890 191
Dependents: 33
Suggesters: 0
Security: 0
Stars: 4
Watchers: 4
Forks: 1
Type:jetpack-library
Requires
- php: >=7.2
Requires (Dev)
- automattic/jetpack-changelogger: ^5.0.0
- brain/monkey: 2.6.1
- yoast/phpunit-polyfills: ^1.1.1
Suggests
- automattic/jetpack-autoloader: Allow for better interoperability with other plugins that use this package.
- dev-trunk / 3.0.x-dev
- v3.0.0
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.6.23
- v1.6.22
- v1.6.21
- v1.6.20
- v1.6.19
- v1.6.18
- v1.6.17
- v1.6.16
- v1.6.15
- v1.6.14
- v1.6.13
- v1.6.12
- v1.6.11
- v1.6.10
- v1.6.9
- v1.6.8
- v1.6.7
- v1.6.6
- v1.6.5
- v1.6.4
- 1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.1
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.0
- dev-prerelease
- dev-fix/slack-workflow-branch-detection
- dev-fix/release-branch-typo
- dev-update/generate-branch-plugin
- dev-release-v1.6.2
- dev-release-v1.6.1
- dev-feature/reorg
- dev-release-v1.6.0
- dev-release-v1.5.1
- dev-release-v1.5.0
- dev-release-v1.4.0
- dev-release-v1.3.0
- dev-release-v1.2.0
This package is auto-updated.
Last update: 2024-11-20 15:14:38 UTC
README
A simple constant manager for Jetpack.
Testing constants is hard. Once you define a constant in PHP, it's defined. Constants Manager is an abstraction layer so that unit tests can set constants for tests.
Usage
Retrieve the value of a constant CONSTANT_NAME
(returns null
if it's not defined):
use Automattic\Jetpack\Constants; $constant_value = Constants::get_constant( 'CONSTANT_NAME' );
Set the value of a constant CONSTANT_NAME
to a particular value:
use Automattic\Jetpack\Constants; $value = 'some value'; Constants::set_constant( 'CONSTANT_NAME', $value );
Check whether a constant CONSTANT_NAME
is defined:
use Automattic\Jetpack\Constants; $defined = Constants::is_defined( 'CONSTANT_NAME' );
Check whether a constant CONSTANT_NAME
is truthy:
use Automattic\Jetpack\Constants; $is_truthy = Constants::is_true( 'CONSTANT_NAME' );
Delete the CONSTANT_NAME
constant:
use Automattic\Jetpack\Constants; Constants::clear_single_constant( 'CONSTANT_NAME' );
Delete all known constants:
use Automattic\Jetpack\Constants; Constants::clear_constants();
Using this package in your WordPress plugin
If you plan on using this package in your WordPress plugin, we would recommend that you use Jetpack Autoloader as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.
Security
Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.
License
jetpack-constants is licensed under GNU General Public License v2 (or later)