| 
1 |  | -<?php declare(strict_types=1);  | 
 | 1 | +<?php  | 
 | 2 | + | 
 | 3 | +declare(strict_types=1);  | 
2 | 4 | 
 
  | 
3 | 5 | namespace SamJUK\CacheDebounce\Model;  | 
4 | 6 | 
 
  | 
 | 
7 | 9 | class Config  | 
8 | 10 | {  | 
9 | 11 |     private const XML_PATH_GENERAL_ENABLED = 'samjuk_cache_debounce/general/enabled';  | 
10 |  | -    private const XML_PATH_CRON_FLUSH = 'samjuk_cache_debounce/cron/flush';  | 
11 | 12 | 
 
  | 
 | 13 | +    /** @var bool $shouldDebouncePurgeRequest */  | 
12 | 14 |     private $shouldDebouncePurgeRequest = true;  | 
13 | 15 | 
 
  | 
 | 16 | +    /** @var ScopeConfigInterface $scopeConfig */  | 
14 | 17 |     private $scopeConfig;  | 
15 |  | -      | 
 | 18 | + | 
16 | 19 |     public function __construct(  | 
17 | 20 |         ScopeConfigInterface $scopeConfig  | 
18 | 21 |     ) {  | 
19 | 22 |         $this->scopeConfig = $scopeConfig;  | 
20 | 23 |     }  | 
21 | 24 | 
 
  | 
22 |  | -    public function isModuleEnabled()  | 
 | 25 | +    /**  | 
 | 26 | +     * Check if the module feature flag is enabled  | 
 | 27 | +     */  | 
 | 28 | +    public function isModuleEnabled() : bool  | 
23 | 29 |     {  | 
24 | 30 |         return $this->getFlag(self::XML_PATH_GENERAL_ENABLED);  | 
25 | 31 |     }  | 
26 | 32 | 
 
  | 
27 |  | -    public function shouldDebouncePurgeRequest()  | 
 | 33 | +    /**  | 
 | 34 | +     * Check if we should debounce this purge request  | 
 | 35 | +     */  | 
 | 36 | +    public function shouldDebouncePurgeRequest() : bool  | 
28 | 37 |     {  | 
29 | 38 |         return $this->isModuleEnabled() && $this->shouldDebouncePurgeRequest;  | 
30 | 39 |     }  | 
31 | 40 | 
 
  | 
32 |  | -    public function setShouldDebouncePurgeRequest($state)  | 
 | 41 | +    /**  | 
 | 42 | +     * Set flag to allow skipping the debounce (for flush workflows)  | 
 | 43 | +     */  | 
 | 44 | +    public function setShouldDebouncePurgeRequest(bool $state) : void  | 
33 | 45 |     {  | 
34 | 46 |         $this->shouldDebouncePurgeRequest = $state;  | 
35 | 47 |     }  | 
36 | 48 | 
 
  | 
37 |  | -    private function getFlag($path, $scope = 'default', $scopeCode = null)  | 
 | 49 | +    /**  | 
 | 50 | +     * Fetch a system config flag  | 
 | 51 | +     */  | 
 | 52 | +    private function getFlag(string $path, ?string $scope = 'default', ?string $scopeCode = null) : bool  | 
38 | 53 |     {  | 
39 | 54 |         return (bool)$this->scopeConfig->isSetFlag($path, $scope, $scopeCode);  | 
40 | 55 |     }  | 
41 | 56 | 
 
  | 
42 |  | -    private function getValue($path, $scope = 'default', $scopeCode = null)  | 
 | 57 | +    /**  | 
 | 58 | +     * Fetch a system config value  | 
 | 59 | +     */  | 
 | 60 | +    private function getValue(string $path, ?string $scope = 'default', ?string $scopeCode = null)  | 
43 | 61 |     {  | 
44 | 62 |         return $this->scopeConfig->getValue($path, $scope, $scopeCode);  | 
45 | 63 |     }  | 
 | 
0 commit comments