Skip to content

Instantly share code, notes, and snippets.

@kasparsd
Created February 20, 2025 12:18
Show Gist options
  • Save kasparsd/d76983fb909d2145d4036f1c8a6f0fa2 to your computer and use it in GitHub Desktop.
Save kasparsd/d76983fb909d2145d4036f1c8a6f0fa2 to your computer and use it in GitHub Desktop.
<?php
namespace YourVendor\Project;
class Config {
private static array $config = [];
private function __construct() {
// Private constructor to prevent direct instantiation
}
private function __clone() {
// Prevent cloning of the instance
}
public static function set( string $key, string $value ): void {
self::$config[ $key ] = $value;
}
public static function get( string $key ): ?string {
return self::$config[ $key ] ?? null;
}
public static function has( string $key ): bool {
return isset( self::$config[ $key ] );
}
public static function delete( string $key ): void {
unset( self::$config[ $key ] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment