Scaffold plugin: architecture contract, schema, settings, fee math

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-15 08:42:30 -08:00
commit 939193f258
12 files changed
+2081

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
<?php
declare( strict_types=1 );
namespace StreamGoals\Core;
/**
* Typed access to the single `sg_settings` option.
*/
final class Settings {
public static function defaults(): array {
return array(
'paypal_mode' => 'sandbox', // sandbox | live
'paypal_client_id' => '',
'paypal_client_secret' => '',
'paypal_webhook_id' => '',
'fee_percent_bps' => 349, // 3.49%
'fee_fixed_minor' => 49,
'anonymity_policy' => 'allow', // allow | require_name | force_anonymous
'moderate_messages' => false,
'profanity_filter' => true,
'message_max_length' => 200,
'min_donation_minor' => 100,
'overlay_token' => '',
);
}
public static function all(): array {
$saved = get_option( 'sg_settings', array() );
return array_merge( self::defaults(), is_array( $saved ) ? $saved : array() );
}
public static function get( string $key, mixed $default = null ): mixed {
$all = self::all();
return $all[ $key ] ?? $default;
}
public static function update( array $values ): void {
$allowed = array_intersect_key( $values, self::defaults() );
update_option( 'sg_settings', array_merge( self::all(), $allowed ), false );
}
public static function fee_calculator(): FeeCalculator {
return new FeeCalculator( (int) self::get( 'fee_percent_bps' ), (int) self::get( 'fee_fixed_minor' ) );
}
}