| 1 |
<?php |
| 2 |
/** |
| 3 |
* An interface that determines the structure of a config strategy. |
| 4 |
* |
| 5 |
* @since 0.1.0 |
| 6 |
* |
| 7 |
* @package SolidWP\Performance |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace SolidWP\Performance\Config\Contracts; |
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Defines how configuration values should be stored & retrieved. |
| 18 |
* |
| 19 |
* @since 0.1.0 |
| 20 |
* |
| 21 |
* @package SolidWP\Performance |
| 22 |
*/ |
| 23 |
interface Strategy { |
| 24 |
|
| 25 |
/** |
| 26 |
* Gets a value from the configuration. |
| 27 |
* |
| 28 |
* @since 0.1.0 |
| 29 |
* |
| 30 |
* @param string $key The key for the value to retrieve. |
| 31 |
* |
| 32 |
* @return mixed|null The value for the key or null if not defined. |
| 33 |
*/ |
| 34 |
public function get( string $key ); |
| 35 |
|
| 36 |
/** |
| 37 |
* Sets a value in the configuration. |
| 38 |
* |
| 39 |
* @since 0.1.0 |
| 40 |
* |
| 41 |
* @param array $changes The changes to save. |
| 42 |
* |
| 43 |
* @return bool True on success, false if config could not be saved. |
| 44 |
*/ |
| 45 |
public function save( array $changes ); |
| 46 |
|
| 47 |
/** |
| 48 |
* Checks that the current strategy is responsible for the passed option. |
| 49 |
* |
| 50 |
* @since 0.1.0 |
| 51 |
* |
| 52 |
* @param string $option_key The key for the option to check. |
| 53 |
* |
| 54 |
* @return bool |
| 55 |
*/ |
| 56 |
public function is_responsible_for( string $option_key ): bool; |
| 57 |
} |
| 58 |
|