← All changes
|
vendor/hostinger/hostinger-wp-helper/src/Config.php
+25
-21
3.0.67
→
trunk
View file →
| @@ -1,30 +1,34 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Hostinger\WpHelper; |
| 4 | 4 | |
| 5 | -defined( 'ABSPATH' ) || exit; | |
| 5 | +defined('ABSPATH') || exit; | |
| 6 | 6 | |
| 7 | -class Config { | |
| 8 | - private array $config = array(); | |
| 9 | - public const TOKEN_HEADER = 'X-Hpanel-Order-Token'; | |
| 10 | - public const DOMAIN_HEADER = 'X-Hpanel-Domain'; | |
| 11 | - public const CONFIG_PATH = ABSPATH . '.private/config.json'; | |
| 12 | - public function __construct() { | |
| 13 | - $this->decodeConfig( self::CONFIG_PATH ); | |
| 14 | - } | |
| 7 | +class Config | |
| 8 | +{ | |
| 9 | + private array $config = array(); | |
| 10 | + public const TOKEN_HEADER = 'X-Hpanel-Order-Token'; | |
| 11 | + public const DOMAIN_HEADER = 'X-Hpanel-Domain'; | |
| 12 | + public const CONFIG_PATH = ABSPATH . '.private/config.json'; | |
| 13 | + public function __construct() | |
| 14 | + { | |
| 15 | + $this->decodeConfig(self::CONFIG_PATH); | |
| 16 | + } | |
| 15 | 17 | |
| 16 | - private function decodeConfig( string $path ): void { | |
| 17 | - if ( file_exists( $path ) ) { | |
| 18 | - $config_content = file_get_contents( $path ); | |
| 19 | - $this->config = json_decode( $config_content, true ); | |
| 20 | - } | |
| 21 | - } | |
| 18 | + private function decodeConfig(string $path): void | |
| 19 | + { | |
| 20 | + if (file_exists($path)) { | |
| 21 | + $config_content = file_get_contents($path); | |
| 22 | + $this->config = json_decode($config_content, true); | |
| 23 | + } | |
| 24 | + } | |
| 22 | 25 | |
| 23 | - public function getConfigValue( string $key, $default ): string { | |
| 24 | - if ( $this->config && isset( $this->config[ $key ] ) && ! empty( $this->config[ $key ] ) ) { | |
| 25 | - return $this->config[ $key ]; | |
| 26 | - } | |
| 26 | + public function getConfigValue(string $key, $default): string | |
| 27 | + { | |
| 28 | + if ($this->config && isset($this->config[ $key ]) && ! empty($this->config[ $key ])) { | |
| 29 | + return $this->config[ $key ]; | |
| 30 | + } | |
| 27 | 31 | |
| 28 | - return $default; | |
| 29 | - } | |
| 32 | + return $default; | |
| 33 | + } | |
| 30 | 34 | } |