PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.8.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.8.0
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Config / Default_Config.php

Default_Config.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.8.0, at src/Performance/Config/Default_Config.php

58 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Contains the default configuration items.
4 *
5 * @package SolidWP\Performance
6 */
7
8 declare( strict_types=1 );
9
10 namespace SolidWP\Performance\Config;
11
12 use SolidWP\Performance\StellarWP\Arrays\Arr;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * Contains the default configuration items.
20 *
21 * @template T of array{page_cache: array{cache_dir: string, debug: bool, enabled: bool, expiration: int, exclusions: string[], compression: array{enabled: bool}, preload: array{high_performance_mode: bool}, lazy_loading: array{enabled: bool}, cache_delivery: array{method: string}, image_transformation: array{enabled: bool, processor: string}}}
22 *
23 * @see Provider::register()
24 *
25 * @package SolidWP\Performance
26 */
27 final class Default_Config {
28
29 /**
30 * The default configuration items.
31 *
32 * @var T
33 */
34 private array $defaults;
35
36 /**
37 * @param array<string, mixed> $defaults The default config items.
38 */
39 public function __construct( array $defaults ) {
40 $this->defaults = $defaults;
41 }
42
43 /**
44 * Get the value of a default config item.
45 *
46 * @param string|null $key The config key, if no key we'll return all items.
47 *
48 * @return mixed|T
49 */
50 public function get( ?string $key = null ) {
51 if ( is_null( $key ) ) {
52 return $this->defaults;
53 }
54
55 return Arr::get( $this->defaults, explode( '.', $key ) );
56 }
57 }
58