Passed
Pull Request — main (#63)
by Sílvio
06:20 queued 03:25
created
src/Utils/CacheDriver.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 {
21 21
 
22 22
     /**
23
-    * @var Cacheer
24
-    */
23
+     * @var Cacheer
24
+     */
25 25
     protected Cacheer $cacheer;
26 26
 
27 27
     /** @param string $logPath */
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
     }
39 39
 
40 40
     /**
41
-    * Uses the database driver for caching.
42
-    * 
43
-    * @return Cacheer
44
-    */
41
+     * Uses the database driver for caching.
42
+     * 
43
+     * @return Cacheer
44
+     */
45 45
     public function useDatabaseDriver(): Cacheer
46 46
     {
47 47
         $this->cacheer->cacheStore = new DatabaseCacheStore($this->logPath, $this->cacheer->options);
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
     }
50 50
 
51 51
     /**
52
-    * Uses the file driver for caching.
53
-    *
54
-    * @return Cacheer
55
-    */
52
+     * Uses the file driver for caching.
53
+     *
54
+     * @return Cacheer
55
+     */
56 56
     public function useFileDriver(): Cacheer
57 57
     {
58 58
         $this->cacheer->options['loggerPath'] = $this->logPath;
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
     }
62 62
 
63 63
     /**
64
-    * Uses the Redis driver for caching.
65
-    * 
66
-    * @return Cacheer
67
-    */
64
+     * Uses the Redis driver for caching.
65
+     * 
66
+     * @return Cacheer
67
+     */
68 68
     public function useRedisDriver(): Cacheer
69 69
     {
70 70
         $this->cacheer->cacheStore = new RedisCacheStore($this->logPath, $this->cacheer->options);
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
     }
73 73
 
74 74
     /**
75
-    * Uses the array driver for caching.
76
-    * 
77
-    * @return Cacheer
78
-    */
75
+     * Uses the array driver for caching.
76
+     * 
77
+     * @return Cacheer
78
+     */
79 79
     public function useArrayDriver(): Cacheer
80 80
     {
81 81
         $this->cacheer->cacheStore = new ArrayCacheStore($this->logPath);
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
     }
84 84
 
85 85
     /**
86
-    * Uses the default driver for caching.
87
-    * 
88
-    * @return Cacheer
89
-    */
86
+     * Uses the default driver for caching.
87
+     * 
88
+     * @return Cacheer
89
+     */
90 90
     public function useDefaultDriver(): Cacheer
91 91
     {
92 92
         if (!isset($this->cacheer->options['cacheDir'])) {
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
     /**
106
-    * Checks if the directory exists or creates it.
107
-    *
108
-    * @param mixed $dirName
109
-    * @return bool
110
-    */
106
+     * Checks if the directory exists or creates it.
107
+     *
108
+     * @param mixed $dirName
109
+     * @return bool
110
+     */
111 111
     private function isDir(mixed $dirName): bool
112 112
     {
113
-      if (is_dir($dirName)) {
114
-          return true;
115
-      }
116
-      return mkdir($dirName, 0755, true);
113
+        if (is_dir($dirName)) {
114
+            return true;
115
+        }
116
+        return mkdir($dirName, 0755, true);
117 117
     }
118 118
 }
Please login to merge, or discard this patch.
src/Config/Option/Builder/OptionBuilder.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -14,33 +14,33 @@
 block discarded – undo
14 14
 class OptionBuilder
15 15
 {
16 16
   
17
-  /**
18
-  * Creates a FileOptionBuilder instance for file-based cache options.
19
-  *
20
-  * @return FileOptionBuilder
21
-  */
22
-  public static function forFile(): FileOptionBuilder
23
-  {
17
+    /**
18
+     * Creates a FileOptionBuilder instance for file-based cache options.
19
+     *
20
+     * @return FileOptionBuilder
21
+     */
22
+    public static function forFile(): FileOptionBuilder
23
+    {
24 24
     return new FileOptionBuilder();
25
-  }
25
+    }
26 26
 
27
-  /**
28
-  * Creates a RedisOptionBuilder instance for Redis cache options.
29
-  *
30
-  * @return RedisOptionBuilder
31
-  */
32
-  public static function forRedis(): RedisOptionBuilder
33
-  {
27
+    /**
28
+     * Creates a RedisOptionBuilder instance for Redis cache options.
29
+     *
30
+     * @return RedisOptionBuilder
31
+     */
32
+    public static function forRedis(): RedisOptionBuilder
33
+    {
34 34
     return new RedisOptionBuilder();
35
-  }
35
+    }
36 36
 
37
-  /**
38
-  * Creates a DatabaseOptionBuilder instance for database cache options.
39
-  *
40
-  * @return DatabaseOptionBuilder
41
-  */
42
-  public static function forDatabase(): DatabaseOptionBuilder
43
-  {
37
+    /**
38
+     * Creates a DatabaseOptionBuilder instance for database cache options.
39
+     *
40
+     * @return DatabaseOptionBuilder
41
+     */
42
+    public static function forDatabase(): DatabaseOptionBuilder
43
+    {
44 44
     return new DatabaseOptionBuilder();
45
-  }
45
+    }
46 46
 }
Please login to merge, or discard this patch.
src/CacheStore/CacheManager/OptionBuilders/DatabaseOptionBuilder.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -13,101 +13,101 @@
 block discarded – undo
13 13
  */
14 14
 class DatabaseOptionBuilder
15 15
 {
16
-  /** @var ?string */
17
-  private ?string $table = null;
18
-
19
-  /** @var ?string */
20
-  private ?string $expirationTime = null;
21
-
22
-  /** @var ?string */
23
-  private ?string $flushAfter = null;
24
-
25
-  /** @var array */
26
-  private array $options = [];
27
-
28
-  /**
29
-   * Sets the database table used for cache storage.
30
-   *
31
-   * @param string $table
32
-   * @return $this
33
-   */
34
-  public function table(string $table): self
35
-  {
16
+    /** @var ?string */
17
+    private ?string $table = null;
18
+
19
+    /** @var ?string */
20
+    private ?string $expirationTime = null;
21
+
22
+    /** @var ?string */
23
+    private ?string $flushAfter = null;
24
+
25
+    /** @var array */
26
+    private array $options = [];
27
+
28
+    /**
29
+     * Sets the database table used for cache storage.
30
+     *
31
+     * @param string $table
32
+     * @return $this
33
+     */
34
+    public function table(string $table): self
35
+    {
36 36
     $this->table = $table;
37 37
     return $this;
38
-  }
39
-
40
-  /**
41
-   * Sets the default expiration time for records.
42
-   *
43
-   * @param ?string $expirationTime
44
-   * @return $this|TimeBuilder
45
-   */
46
-  public function expirationTime(?string $expirationTime = null)
47
-  {
38
+    }
39
+
40
+    /**
41
+     * Sets the default expiration time for records.
42
+     *
43
+     * @param ?string $expirationTime
44
+     * @return $this|TimeBuilder
45
+     */
46
+    public function expirationTime(?string $expirationTime = null)
47
+    {
48 48
     if (!is_null($expirationTime)) {
49
-      $this->expirationTime = $expirationTime;
50
-      return $this;
49
+        $this->expirationTime = $expirationTime;
50
+        return $this;
51 51
     }
52 52
 
53 53
     return new TimeBuilder(function ($formattedTime) {
54
-      $this->expirationTime = $formattedTime;
54
+        $this->expirationTime = $formattedTime;
55 55
     }, $this);
56
-  }
57
-
58
-  /**
59
-   * Sets an auto-flush interval for database cache.
60
-   *
61
-   * @param ?string $flushAfter
62
-   * @return $this|TimeBuilder
63
-   */
64
-  public function flushAfter(?string $flushAfter = null)
65
-  {
56
+    }
57
+
58
+    /**
59
+     * Sets an auto-flush interval for database cache.
60
+     *
61
+     * @param ?string $flushAfter
62
+     * @return $this|TimeBuilder
63
+     */
64
+    public function flushAfter(?string $flushAfter = null)
65
+    {
66 66
     if (!is_null($flushAfter)) {
67
-      $this->flushAfter = mb_strtolower($flushAfter, 'UTF-8');
68
-      return $this;
67
+        $this->flushAfter = mb_strtolower($flushAfter, 'UTF-8');
68
+        return $this;
69 69
     }
70 70
 
71 71
     return new TimeBuilder(function ($formattedTime) {
72
-      $this->flushAfter = $formattedTime;
72
+        $this->flushAfter = $formattedTime;
73 73
     }, $this);
74
-  }
75
-
76
-  /**
77
-   * Builds the options array.
78
-   *
79
-   * @return array
80
-   */
81
-  public function build(): array
82
-  {
74
+    }
75
+
76
+    /**
77
+     * Builds the options array.
78
+     *
79
+     * @return array
80
+     */
81
+    public function build(): array
82
+    {
83 83
     return $this->validated();
84
-  }
85
-
86
-  /**
87
-   * Validate and assemble options.
88
-   * @return array
89
-   */
90
-  private function validated(): array
91
-  {
84
+    }
85
+
86
+    /**
87
+     * Validate and assemble options.
88
+     * @return array
89
+     */
90
+    private function validated(): array
91
+    {
92 92
     foreach ($this->properties() as $key => $value) {
93
-      if (!empty($value)) {
93
+        if (!empty($value)) {
94 94
         $this->options[$key] = $value;
95
-      }
95
+        }
96 96
     }
97 97
     return $this->options;
98
-  }
99
-
100
-  /**
101
-   * Returns current properties.
102
-   * @return array
103
-   */
104
-  private function properties(): array
105
-  {
98
+    }
99
+
100
+    /**
101
+     * Returns current properties.
102
+     * @return array
103
+     */
104
+    private function properties(): array
105
+    {
106 106
     return [
107
-      'table'          => $this->table,
108
-      'expirationTime' => $this->expirationTime,
109
-      'flushAfter'     => $this->flushAfter,
107
+        'table'          => $this->table,
108
+        'expirationTime' => $this->expirationTime,
109
+        'flushAfter'     => $this->flushAfter,
110 110
     ];
111
-  }
111
+    }
112 112
 }
113 113
 
Please login to merge, or discard this patch.
src/CacheStore/CacheManager/OptionBuilders/RedisOptionBuilder.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -13,101 +13,101 @@
 block discarded – undo
13 13
  */
14 14
 class RedisOptionBuilder
15 15
 {
16
-  /** @var ?string */
17
-  private ?string $namespace = null;
18
-
19
-  /** @var ?string */
20
-  private ?string $expirationTime = null;
21
-
22
-  /** @var ?string */
23
-  private ?string $flushAfter = null;
24
-
25
-  /** @var array */
26
-  private array $options = [];
27
-
28
-  /**
29
-   * Sets the Redis key namespace prefix.
30
-   *
31
-   * @param string $namespace
32
-   * @return $this
33
-   */
34
-  public function setNamespace(string $namespace): self
35
-  {
16
+    /** @var ?string */
17
+    private ?string $namespace = null;
18
+
19
+    /** @var ?string */
20
+    private ?string $expirationTime = null;
21
+
22
+    /** @var ?string */
23
+    private ?string $flushAfter = null;
24
+
25
+    /** @var array */
26
+    private array $options = [];
27
+
28
+    /**
29
+     * Sets the Redis key namespace prefix.
30
+     *
31
+     * @param string $namespace
32
+     * @return $this
33
+     */
34
+    public function setNamespace(string $namespace): self
35
+    {
36 36
     $this->namespace = $namespace;
37 37
     return $this;
38
-  }
39
-
40
-  /**
41
-   * Sets the default expiration time for keys.
42
-   *
43
-   * @param ?string $expirationTime
44
-   * @return $this|TimeBuilder
45
-   */
46
-  public function expirationTime(?string $expirationTime = null)
47
-  {
38
+    }
39
+
40
+    /**
41
+     * Sets the default expiration time for keys.
42
+     *
43
+     * @param ?string $expirationTime
44
+     * @return $this|TimeBuilder
45
+     */
46
+    public function expirationTime(?string $expirationTime = null)
47
+    {
48 48
     if (!is_null($expirationTime)) {
49
-      $this->expirationTime = $expirationTime;
50
-      return $this;
49
+        $this->expirationTime = $expirationTime;
50
+        return $this;
51 51
     }
52 52
 
53 53
     return new TimeBuilder(function ($formattedTime) {
54
-      $this->expirationTime = $formattedTime;
54
+        $this->expirationTime = $formattedTime;
55 55
     }, $this);
56
-  }
57
-
58
-  /**
59
-   * Sets the auto-flush interval.
60
-   *
61
-   * @param ?string $flushAfter
62
-   * @return $this|TimeBuilder
63
-   */
64
-  public function flushAfter(?string $flushAfter = null)
65
-  {
56
+    }
57
+
58
+    /**
59
+     * Sets the auto-flush interval.
60
+     *
61
+     * @param ?string $flushAfter
62
+     * @return $this|TimeBuilder
63
+     */
64
+    public function flushAfter(?string $flushAfter = null)
65
+    {
66 66
     if (!is_null($flushAfter)) {
67
-      $this->flushAfter = mb_strtolower($flushAfter, 'UTF-8');
68
-      return $this;
67
+        $this->flushAfter = mb_strtolower($flushAfter, 'UTF-8');
68
+        return $this;
69 69
     }
70 70
 
71 71
     return new TimeBuilder(function ($formattedTime) {
72
-      $this->flushAfter = $formattedTime;
72
+        $this->flushAfter = $formattedTime;
73 73
     }, $this);
74
-  }
75
-
76
-  /**
77
-   * Builds the options array.
78
-   *
79
-   * @return array
80
-   */
81
-  public function build(): array
82
-  {
74
+    }
75
+
76
+    /**
77
+     * Builds the options array.
78
+     *
79
+     * @return array
80
+     */
81
+    public function build(): array
82
+    {
83 83
     return $this->validated();
84
-  }
85
-
86
-  /**
87
-   * Validate and assemble options.
88
-   * @return array
89
-   */
90
-  private function validated(): array
91
-  {
84
+    }
85
+
86
+    /**
87
+     * Validate and assemble options.
88
+     * @return array
89
+     */
90
+    private function validated(): array
91
+    {
92 92
     foreach ($this->properties() as $key => $value) {
93
-      if (!empty($value)) {
93
+        if (!empty($value)) {
94 94
         $this->options[$key] = $value;
95
-      }
95
+        }
96 96
     }
97 97
     return $this->options;
98
-  }
99
-
100
-  /**
101
-   * Returns current properties.
102
-   * @return array
103
-   */
104
-  private function properties(): array
105
-  {
98
+    }
99
+
100
+    /**
101
+     * Returns current properties.
102
+     * @return array
103
+     */
104
+    private function properties(): array
105
+    {
106 106
     return [
107
-      'namespace'      => $this->namespace,
108
-      'expirationTime' => $this->expirationTime,
109
-      'flushAfter'     => $this->flushAfter,
107
+        'namespace'      => $this->namespace,
108
+        'expirationTime' => $this->expirationTime,
109
+        'flushAfter'     => $this->flushAfter,
110 110
     ];
111
-  }
111
+    }
112 112
 }
113 113
 
Please login to merge, or discard this patch.
src/Support/TimeBuilder.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -12,24 +12,24 @@  discard block
 block discarded – undo
12 12
 class TimeBuilder
13 13
 {
14 14
     
15
-  /** @param Closure $callback */
16
-  private Closure $callback;
15
+    /** @param Closure $callback */
16
+    private Closure $callback;
17 17
 
18
-  /** @var mixed */
19
-  private $builder = null;
18
+    /** @var mixed */
19
+    private $builder = null;
20 20
 
21
-  /**
22
-  * TimeBuilder constructor.
23
-  * @param Closure $callback
24
-  * @param mixed $builder
25
-  *
26
-  * @return void
27
-  */
28
-  public function __construct(Closure $callback, $builder)
29
-  {
21
+    /**
22
+     * TimeBuilder constructor.
23
+     * @param Closure $callback
24
+     * @param mixed $builder
25
+     *
26
+     * @return void
27
+     */
28
+    public function __construct(Closure $callback, $builder)
29
+    {
30 30
     $this->callback = $callback;
31 31
     $this->builder = $builder;
32
-  }
32
+    }
33 33
 
34 34
     /**
35 35
      * Sets the time in seconds.
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
      * @param int $seconds
38 38
      * @return mixed
39 39
      */
40
-  public function second(int $seconds)
41
-  {
40
+    public function second(int $seconds)
41
+    {
42 42
     return $this->setTime($seconds, "seconds");
43
-  }
43
+    }
44 44
 
45 45
     /**
46 46
      * Sets the time in minutes.
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
      * @param int $minutes
49 49
      * @return mixed
50 50
      */
51
-  public function minute(int $minutes)
52
-  {
51
+    public function minute(int $minutes)
52
+    {
53 53
     return $this->setTime($minutes, "minutes");
54
-  }
54
+    }
55 55
 
56 56
     /**
57 57
      * Sets the time in hours.
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
      * @param int $hours
60 60
      * @return mixed
61 61
      */
62
-  public function hour(int $hours)
63
-  {
62
+    public function hour(int $hours)
63
+    {
64 64
     return $this->setTime($hours, "hours");
65
-  }
65
+    }
66 66
 
67 67
     /**
68 68
      * Sets the time in days.
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
      * @param int $days
71 71
      * @return mixed
72 72
      */
73
-  public function day(int $days)
74
-  {
73
+    public function day(int $days)
74
+    {
75 75
     return $this->setTime($days, "days");
76
-  }
76
+    }
77 77
 
78 78
     /**
79 79
      * Sets the time in weeks.
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
      * @param int $weeks
82 82
      * @return mixed
83 83
      */
84
-  public function week(int $weeks)
85
-  {
84
+    public function week(int $weeks)
85
+    {
86 86
     return $this->setTime($weeks, "weeks");
87
-  }
87
+    }
88 88
 
89 89
     /**
90 90
      * Sets the time in months.
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
      * @param int $months
93 93
      * @return mixed
94 94
      */
95
-  public function month(int $months)
96
-  {
95
+    public function month(int $months)
96
+    {
97 97
     return $this->setTime($months, "months");
98
-  }
98
+    }
99 99
 
100 100
 
101 101
     /**
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
      * @param string $unit
106 106
      * @return mixed
107 107
      */
108
-  private function setTime(int $value, string $unit)
109
-  {
110
-   ($this->callback)("{$value} {$unit}");
108
+    private function setTime(int $value, string $unit)
109
+    {
110
+    ($this->callback)("{$value} {$unit}");
111 111
     return $this->builder;
112
-  }
112
+    }
113 113
 
114 114
 }
Please login to merge, or discard this patch.
src/Repositories/CacheDatabaseRepository.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
     }
65 65
 
66 66
     /**
67
-    * Retrieves cache data from the database.
68
-    * 
69
-    * @param string $cacheKey
70
-    * @param string $namespace
71
-    * @return mixed
67
+     * Retrieves cache data from the database.
68
+     * 
69
+     * @param string $cacheKey
70
+     * @param string $namespace
71
+     * @return mixed
72 72
      */
73 73
     public function retrieve(string $cacheKey, string $namespace = ''): mixed
74 74
     {
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
     }
114 114
 
115 115
     /**
116
-    * Get Update query based on the database driver.
117
-    *
118
-    * @return string
119
-    */
116
+     * Get Update query based on the database driver.
117
+     *
118
+     * @return string
119
+     */
120 120
     private function getUpdateQueryWithDriver(): string
121 121
     {
122 122
         $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME);
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
     }
128 128
 
129 129
     /**
130
-    * Get Delete query based on the database driver.
131
-    * 
132
-    * @return string
133
-    */
130
+     * Get Delete query based on the database driver.
131
+     * 
132
+     * @return string
133
+     */
134 134
     private function getDeleteQueryWithDriver(): string
135 135
     {
136 136
         $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME);
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
     }
142 142
 
143 143
     /**
144
-    * Updates an existing cache item in the database.
145
-    * 
146
-    * @param string $cacheKey
147
-    * @param mixed  $cacheData
148
-    * @param string $namespace
149
-    * @return bool
150
-    */
144
+     * Updates an existing cache item in the database.
145
+     * 
146
+     * @param string $cacheKey
147
+     * @param mixed  $cacheData
148
+     * @param string $namespace
149
+     * @return bool
150
+     */
151 151
     public function update(string $cacheKey, mixed $cacheData, string $namespace = ''): bool
152 152
     {
153 153
         $query = $this->getUpdateQueryWithDriver();
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
     }
162 162
 
163 163
     /**
164
-    * Clears a specific cache item from the database.
165
-    * 
166
-    * @param string $cacheKey
167
-    * @param string $namespace
168
-    * @return bool
169
-    */
164
+     * Clears a specific cache item from the database.
165
+     * 
166
+     * @param string $cacheKey
167
+     * @param string $namespace
168
+     * @return bool
169
+     */
170 170
     public function clear(string $cacheKey, string $namespace = ''): bool
171 171
     {
172 172
         $query = $this->getDeleteQueryWithDriver();
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
     }
180 180
 
181 181
     /**
182
-    * Gets the query to renew the expiration time of a cache item based on the database driver.
183
-    *  
184
-    * @return string
185
-    */
182
+     * Gets the query to renew the expiration time of a cache item based on the database driver.
183
+     *  
184
+     * @return string
185
+     */
186 186
     private function getRenewExpirationQueryWithDriver(): string
187 187
     {
188 188
         $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME);
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
     }
198 198
 
199 199
     /**
200
-    * Checks if a cache item is valid based on its key, namespace, and current time.
201
-    * 
202
-    * @param string $cacheKey
203
-    * @param string $namespace
204
-    * @param string $currentTime
205
-    * @return bool
206
-    */
200
+     * Checks if a cache item is valid based on its key, namespace, and current time.
201
+     * 
202
+     * @param string $cacheKey
203
+     * @param string $namespace
204
+     * @param string $currentTime
205
+     * @return bool
206
+     */
207 207
     private function hasValidCache(string $cacheKey, string $namespace, string $currentTime): bool
208 208
     {
209 209
         $stmt = $this->connection->prepare(
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
     }
220 220
 
221 221
     /**
222
-    * Renews the expiration time of a cache item.
223
-    * 
224
-    * @param string $cacheKey
225
-    * @param string|int $ttl
226
-    * @param string $namespace
227
-    * @return bool
228
-    */
222
+     * Renews the expiration time of a cache item.
223
+     * 
224
+     * @param string $cacheKey
225
+     * @param string|int $ttl
226
+     * @param string $namespace
227
+     * @return bool
228
+     */
229 229
     public function renew(string $cacheKey, string|int $ttl, string $namespace = ''): bool
230 230
     {
231 231
         $currentTime = date('Y-m-d H:i:s');
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
     }
246 246
 
247 247
     /**
248
-    * Flushes all cache items from the database.
249
-    * 
250
-    * @return bool
251
-    */
248
+     * Flushes all cache items from the database.
249
+     * 
250
+     * @return bool
251
+     */
252 252
     public function flush(): bool
253 253
     {
254 254
         return $this->connection->exec("DELETE FROM {$this->table}") !== false;
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
     }
268 268
 
269 269
     /**
270
-    * Gets the current date and time based on the database driver.
271
-    * 
272
-    * @param string $driver
273
-    * @return string
274
-    */
270
+     * Gets the current date and time based on the database driver.
271
+     * 
272
+     * @param string $driver
273
+     * @return string
274
+     */
275 275
     private function getCurrentDateTime(string $driver): string
276 276
     {
277 277
         return ($driver === 'sqlite') ? "DATETIME('now', 'localtime')" : "NOW()";
Please login to merge, or discard this patch.
tests/Unit/MigrationManagerDynamicTableTest.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@  discard block
 block discarded – undo
7 7
 
8 8
 class MigrationManagerDynamicTableTest extends TestCase
9 9
 {
10
-  private ?PDO $pdo = null;
11
-  private string $table;
10
+    private ?PDO $pdo = null;
11
+    private string $table;
12 12
 
13
-  protected function setUp(): void
14
-  {
13
+    protected function setUp(): void
14
+    {
15 15
     $this->pdo = Connect::getInstance();
16 16
     $this->table = uniqid('mm_custom_table_');
17 17
     // Ensure clean start
18 18
     $this->pdo->exec("DROP TABLE IF EXISTS {$this->table}");
19
-  }
19
+    }
20 20
 
21
-  protected function tearDown(): void
22
-  {
21
+    protected function tearDown(): void
22
+    {
23 23
     if ($this->pdo) {
24
-      $this->pdo->exec("DROP TABLE IF EXISTS {$this->table}");
24
+        $this->pdo->exec("DROP TABLE IF EXISTS {$this->table}");
25
+    }
25 26
     }
26
-  }
27 27
 
28
-  public function test_migrate_creates_custom_table()
29
-  {
28
+    public function test_migrate_creates_custom_table()
29
+    {
30 30
     MigrationManager::migrate($this->pdo, $this->table);
31 31
 
32 32
     // Verify table exists (SQLite check)
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
     $stmt->execute();
51 51
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
52 52
     $this->assertEquals(['a' => 1], unserialize($row['cacheData']));
53
-  }
53
+    }
54 54
 
55
-  public function test_default_constant_table_exists()
56
-  {
55
+    public function test_default_constant_table_exists()
56
+    {
57 57
     // With boot autoload, the default CACHEER_TABLE should be created via Connect::getInstance()
58 58
     $stmt = $this->pdo->query("SELECT name FROM sqlite_master WHERE type='table' AND name = 'cacheer_table'");
59 59
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
60 60
     $this->assertNotFalse($row);
61
-  }
61
+    }
62 62
 }
Please login to merge, or discard this patch.
src/CacheStore/ArrayCacheStore.php 1 patch
Indentation   +317 added lines, -317 removed lines patch added patch discarded remove patch
@@ -13,117 +13,117 @@  discard block
 block discarded – undo
13 13
 class ArrayCacheStore implements CacheerInterface
14 14
 {
15 15
 
16
-  /**
17
-  * @param array $arrayStore
18
-  */
19
-  private array $arrayStore = [];
20
-
21
-  /**
22
-   * @var boolean
23
-   */
24
-  private bool $success = false;
25
-
26
-  /**
27
-   * @var string
28
-   */
29
-  private string $message = '';
30
-
31
-  /**
32
-   * @var ?CacheLogger
33
-   */
34
-  private ?CacheLogger $logger = null;
35
-
36
-  /**
37
-   * @var array<string, array<string,bool>>
38
-   */
39
-  private array $tags = [];
40
-
41
-  /**
42
-   * ArrayCacheStore constructor.
43
-   * 
44
-   * @param string $logPath
45
-   */
46
-  public function __construct(string $logPath)
47
-  {
16
+    /**
17
+     * @param array $arrayStore
18
+     */
19
+    private array $arrayStore = [];
20
+
21
+    /**
22
+     * @var boolean
23
+     */
24
+    private bool $success = false;
25
+
26
+    /**
27
+     * @var string
28
+     */
29
+    private string $message = '';
30
+
31
+    /**
32
+     * @var ?CacheLogger
33
+     */
34
+    private ?CacheLogger $logger = null;
35
+
36
+    /**
37
+     * @var array<string, array<string,bool>>
38
+     */
39
+    private array $tags = [];
40
+
41
+    /**
42
+     * ArrayCacheStore constructor.
43
+     * 
44
+     * @param string $logPath
45
+     */
46
+    public function __construct(string $logPath)
47
+    {
48 48
     $this->logger = new CacheLogger($logPath);
49
-  }
50
-
51
-  /**
52
-   * Appends data to an existing cache item.
53
-   * 
54
-   * @param string $cacheKey
55
-   * @param mixed  $cacheData
56
-   * @param string $namespace
57
-   * @return bool
58
-   */
59
-  public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = ''): bool
60
-  {
61
-      $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
62
-
63
-      if (!$this->has($cacheKey, $namespace)) {
64
-          $this->setMessage("cacheData can't be appended, because doesn't exist or expired", false);
65
-          $this->logger->debug("{$this->getMessage()} from array driver.");
66
-          return false;
67
-      }
68
-
69
-      $this->arrayStore[$arrayStoreKey]['cacheData'] = serialize($cacheData);
70
-      $this->setMessage("Cache appended successfully", true);
71
-      return true;
72
-  }
73
-
74
-  /**
75
-   * Builds a unique key for the array store.
76
-   * 
77
-   * @param string $cacheKey
78
-   * @param string $namespace
79
-   * @return string
80
-   */
81
-  private function buildArrayKey(string $cacheKey, string $namespace = ''): string
82
-  {
49
+    }
50
+
51
+    /**
52
+     * Appends data to an existing cache item.
53
+     * 
54
+     * @param string $cacheKey
55
+     * @param mixed  $cacheData
56
+     * @param string $namespace
57
+     * @return bool
58
+     */
59
+    public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = ''): bool
60
+    {
61
+        $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
62
+
63
+        if (!$this->has($cacheKey, $namespace)) {
64
+            $this->setMessage("cacheData can't be appended, because doesn't exist or expired", false);
65
+            $this->logger->debug("{$this->getMessage()} from array driver.");
66
+            return false;
67
+        }
68
+
69
+        $this->arrayStore[$arrayStoreKey]['cacheData'] = serialize($cacheData);
70
+        $this->setMessage("Cache appended successfully", true);
71
+        return true;
72
+    }
73
+
74
+    /**
75
+     * Builds a unique key for the array store.
76
+     * 
77
+     * @param string $cacheKey
78
+     * @param string $namespace
79
+     * @return string
80
+     */
81
+    private function buildArrayKey(string $cacheKey, string $namespace = ''): string
82
+    {
83 83
     return !empty($namespace) ? ($namespace . ':' . $cacheKey) : $cacheKey;
84
-  }
85
-
86
-  /**
87
-   * Clears a specific cache item.
88
-   * 
89
-   * @param string $cacheKey
90
-   * @param string $namespace
91
-   * @return void
92
-   */
93
-  public function clearCache(string $cacheKey, string $namespace = ''): void
94
-  {
84
+    }
85
+
86
+    /**
87
+     * Clears a specific cache item.
88
+     * 
89
+     * @param string $cacheKey
90
+     * @param string $namespace
91
+     * @return void
92
+     */
93
+    public function clearCache(string $cacheKey, string $namespace = ''): void
94
+    {
95 95
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
96 96
     unset($this->arrayStore[$arrayStoreKey]);
97 97
     $this->setMessage("Cache cleared successfully", true);
98 98
     $this->logger->debug("{$this->getMessage()} from array driver.");
99
-  }
100
-
101
-  /**
102
-   * Decrements a cache item by a specified amount.
103
-   * 
104
-   * @param string $cacheKey
105
-   * @param int $amount
106
-   * @param string $namespace
107
-   * @return bool
108
-   */
109
-  public function decrement(string $cacheKey, int $amount = 1, string $namespace = ''): bool
110
-  {
99
+    }
100
+
101
+    /**
102
+     * Decrements a cache item by a specified amount.
103
+     * 
104
+     * @param string $cacheKey
105
+     * @param int $amount
106
+     * @param string $namespace
107
+     * @return bool
108
+     */
109
+    public function decrement(string $cacheKey, int $amount = 1, string $namespace = ''): bool
110
+    {
111 111
     return $this->increment($cacheKey, ($amount * -1), $namespace);
112
-  }
113
-
114
-  /**
115
-   * Flushes all cache items.
116
-   * 
117
-   * @return void
118
-   */
119
-  public function flushCache(): void
120
-  {
112
+    }
113
+
114
+    /**
115
+     * Flushes all cache items.
116
+     * 
117
+     * @return void
118
+     */
119
+    public function flushCache(): void
120
+    {
121 121
     unset($this->arrayStore);
122 122
     $this->arrayStore = [];
123 123
     $this->tags = [];
124 124
     $this->setMessage("Cache flushed successfully", true);
125 125
     $this->logger->debug("{$this->getMessage()} from array driver.");
126
-  }
126
+    }
127 127
 
128 128
     /**
129 129
      * Stores a cache item permanently.
@@ -132,234 +132,234 @@  discard block
 block discarded – undo
132 132
      * @param mixed $cacheData
133 133
      * @return void
134 134
      */
135
-  public function forever(string $cacheKey, mixed $cacheData): void
136
-  {
135
+    public function forever(string $cacheKey, mixed $cacheData): void
136
+    {
137 137
     $this->putCache($cacheKey, $cacheData, ttl: 31536000 * 1000);
138 138
     $this->setMessage($this->getMessage(), $this->isSuccess());
139
-  }
140
-
141
-  /**
142
-   * Retrieves a single cache item.
143
-   * 
144
-   * @param string $cacheKey
145
-   * @param string $namespace
146
-   * @param int|string $ttl
147
-   * @return mixed
148
-   */
149
-  public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed
150
-  {
139
+    }
140
+
141
+    /**
142
+     * Retrieves a single cache item.
143
+     * 
144
+     * @param string $cacheKey
145
+     * @param string $namespace
146
+     * @param int|string $ttl
147
+     * @return mixed
148
+     */
149
+    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed
150
+    {
151 151
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
152 152
 
153 153
     if (!$this->has($cacheKey, $namespace)) {
154
-      $this->handleCacheNotFound();
155
-      return false;
154
+        $this->handleCacheNotFound();
155
+        return false;
156 156
     }
157 157
 
158 158
     $cacheData = $this->arrayStore[$arrayStoreKey];
159 159
     if ($this->isExpired($cacheData)) {
160
-      $this->handleCacheExpired($arrayStoreKey);
161
-      return false;
160
+        $this->handleCacheExpired($arrayStoreKey);
161
+        return false;
162 162
     }
163 163
 
164 164
     $this->setMessage("Cache retrieved successfully", true);
165 165
     $this->logger->debug("{$this->getMessage()} from array driver.");
166 166
     return $this->serialize($cacheData['cacheData'], false);
167
-  }
168
-
169
-  /**
170
-   * Verify if the cache is expired.
171
-   * 
172
-   * @param array $cacheData
173
-   * @return bool
174
-   */
175
-  private function isExpired(array $cacheData): bool
176
-  {
167
+    }
168
+
169
+    /**
170
+     * Verify if the cache is expired.
171
+     * 
172
+     * @param array $cacheData
173
+     * @return bool
174
+     */
175
+    private function isExpired(array $cacheData): bool
176
+    {
177 177
     $expirationTime = $cacheData['expirationTime'] ?? 0;
178 178
     $now = time();
179 179
     return $expirationTime !== 0 && $now >= $expirationTime;
180
-  }
181
-
182
-  /**
183
-   * Handles the case when cache data is not found.
184
-   * 
185
-   * @return void
186
-   */
187
-  private function handleCacheNotFound(): void
188
-  {
180
+    }
181
+
182
+    /**
183
+     * Handles the case when cache data is not found.
184
+     * 
185
+     * @return void
186
+     */
187
+    private function handleCacheNotFound(): void
188
+    {
189 189
     $this->setMessage("cacheData not found, does not exists or expired", false);
190 190
     $this->logger->debug("{$this->getMessage()} from array driver.");
191
-  }
192
-
193
-  /**
194
-   * Handles the case when cache data has expired.
195
-   * 
196
-   * @param string $arrayStoreKey
197
-   * @return void
198
-   */
199
-  private function handleCacheExpired(string $arrayStoreKey): void
200
-  {
191
+    }
192
+
193
+    /**
194
+     * Handles the case when cache data has expired.
195
+     * 
196
+     * @param string $arrayStoreKey
197
+     * @return void
198
+     */
199
+    private function handleCacheExpired(string $arrayStoreKey): void
200
+    {
201 201
     $parts = explode(':', $arrayStoreKey, 2);
202 202
     if (count($parts) === 2) {
203
-      list($np, $key) = $parts;
203
+        list($np, $key) = $parts;
204 204
     } else {
205
-      $np = '';
206
-      $key = $arrayStoreKey;
205
+        $np = '';
206
+        $key = $arrayStoreKey;
207 207
     }
208 208
     $this->clearCache($key, $np);
209 209
     $this->setMessage("cacheKey: {$key} has expired.", false);
210 210
     $this->logger->debug("{$this->getMessage()} from array driver.");
211
-  }
212
-
213
-  /**
214
-   * Gets all items in a specific namespace.
215
-   * 
216
-   * @param string $namespace
217
-   * @return array
218
-   */
219
-  public function getAll(string $namespace = ''): array
220
-  {
211
+    }
212
+
213
+    /**
214
+     * Gets all items in a specific namespace.
215
+     * 
216
+     * @param string $namespace
217
+     * @return array
218
+     */
219
+    public function getAll(string $namespace = ''): array
220
+    {
221 221
     $results = [];
222 222
     foreach ($this->arrayStore as $key => $data) {
223
-      if (str_starts_with($key, $namespace . ':') || empty($namespace)) {
223
+        if (str_starts_with($key, $namespace . ':') || empty($namespace)) {
224 224
         $results[$key] = $this->serialize($data['cacheData'], false);
225
-      }
225
+        }
226 226
     }
227 227
     return $results;
228
-  }
229
-
230
-  /**
231
-   * Retrieves multiple cache items by their keys.
232
-   * 
233
-   * @param array $cacheKeys
234
-   * @param string $namespace
235
-   * @param string|int $ttl
236
-   * @return array
237
-   */
238
-  public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array
239
-  {
228
+    }
229
+
230
+    /**
231
+     * Retrieves multiple cache items by their keys.
232
+     * 
233
+     * @param array $cacheKeys
234
+     * @param string $namespace
235
+     * @param string|int $ttl
236
+     * @return array
237
+     */
238
+    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array
239
+    {
240 240
     $results = [];
241 241
     foreach ($cacheKeys as $cacheKey) {
242
-      $results[$cacheKey] = $this->getCache($cacheKey, $namespace, $ttl);
242
+        $results[$cacheKey] = $this->getCache($cacheKey, $namespace, $ttl);
243 243
     }
244 244
     return $results;
245
-  }
246
-
247
-  /**
248
-   * Checks if a cache item exists.
249
-   * 
250
-   * @param string $cacheKey
251
-   * @param string $namespace
252
-   * @return bool
253
-   */
254
-  public function has(string $cacheKey, string $namespace = ''): bool
255
-  {
245
+    }
246
+
247
+    /**
248
+     * Checks if a cache item exists.
249
+     * 
250
+     * @param string $cacheKey
251
+     * @param string $namespace
252
+     * @return bool
253
+     */
254
+    public function has(string $cacheKey, string $namespace = ''): bool
255
+    {
256 256
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
257 257
     $exists = isset($this->arrayStore[$arrayStoreKey]) && time() < $this->arrayStore[$arrayStoreKey]['expirationTime'];
258 258
 
259 259
     $this->setMessage(
260
-      $exists ? "Cache key: {$cacheKey} exists and it's available!" : "Cache key: {$cacheKey} does not exist or it's expired!",
261
-      $exists
260
+        $exists ? "Cache key: {$cacheKey} exists and it's available!" : "Cache key: {$cacheKey} does not exist or it's expired!",
261
+        $exists
262 262
     );
263 263
     $this->logger->debug("{$this->getMessage()} from array driver.");
264 264
 
265 265
     return $exists;
266
-  }
267
-
268
-  /**
269
-   * Increments a cache item by a specified amount.
270
-   * 
271
-   * @param string $cacheKey
272
-   * @param int $amount
273
-   * @param string $namespace
274
-   * @return bool
275
-   */
276
-  public function increment(string $cacheKey, int $amount = 1, string $namespace = ''): bool
277
-  {
266
+    }
267
+
268
+    /**
269
+     * Increments a cache item by a specified amount.
270
+     * 
271
+     * @param string $cacheKey
272
+     * @param int $amount
273
+     * @param string $namespace
274
+     * @return bool
275
+     */
276
+    public function increment(string $cacheKey, int $amount = 1, string $namespace = ''): bool
277
+    {
278 278
     $cacheData = $this->getCache($cacheKey, $namespace);
279 279
 
280 280
     if(!empty($cacheData) && is_numeric($cacheData)) {
281
-      $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
282
-      $this->setMessage($this->getMessage(), $this->isSuccess());
283
-      return true;
281
+        $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
282
+        $this->setMessage($this->getMessage(), $this->isSuccess());
283
+        return true;
284 284
     }
285 285
 
286 286
     return false;
287
-  }
288
-
289
-  /**
290
-   * Checks if the operation was successful.
291
-   * 
292
-   * @return boolean
293
-   */
294
-  public function isSuccess(): bool
295
-  {
287
+    }
288
+
289
+    /**
290
+     * Checks if the operation was successful.
291
+     * 
292
+     * @return boolean
293
+     */
294
+    public function isSuccess(): bool
295
+    {
296 296
     return $this->success;
297
-  }
298
-
299
-  /**
300
-   * Gets the last message.
301
-   * 
302
-   * @return string
303
-   */
304
-  public function getMessage(): string
305
-  {
297
+    }
298
+
299
+    /**
300
+     * Gets the last message.
301
+     * 
302
+     * @return string
303
+     */
304
+    public function getMessage(): string
305
+    {
306 306
     return $this->message;
307
-  }
308
-
309
-  /**
310
-   * Stores an item in the cache with a specific TTL.
311
-   * 
312
-   * @param string $cacheKey
313
-   * @param mixed $cacheData
314
-   * @param string $namespace
315
-   * @param int|string $ttl
316
-   * @return bool
317
-   */
318
-  public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool
319
-  {
307
+    }
308
+
309
+    /**
310
+     * Stores an item in the cache with a specific TTL.
311
+     * 
312
+     * @param string $cacheKey
313
+     * @param mixed $cacheData
314
+     * @param string $namespace
315
+     * @param int|string $ttl
316
+     * @return bool
317
+     */
318
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool
319
+    {
320 320
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
321 321
 
322 322
     $this->arrayStore[$arrayStoreKey] = [
323
-      'cacheData' => serialize($cacheData),
324
-      'expirationTime' => time() + $ttl
323
+        'cacheData' => serialize($cacheData),
324
+        'expirationTime' => time() + $ttl
325 325
     ];
326 326
 
327 327
     $this->setMessage("Cache stored successfully", true);
328 328
     $this->logger->debug("{$this->getMessage()} from Array driver.");
329 329
     return true;
330
-  }
331
-
332
-  /**
333
-   * Stores multiple items in the cache in batches.
334
-   * 
335
-   * @param array $items
336
-   * @param string $namespace
337
-   * @param int $batchSize
338
-   * @return void
339
-   */
340
-  public function putMany(array $items, string $namespace = '', int $batchSize = 100): void
341
-  {
330
+    }
331
+
332
+    /**
333
+     * Stores multiple items in the cache in batches.
334
+     * 
335
+     * @param array $items
336
+     * @param string $namespace
337
+     * @param int $batchSize
338
+     * @return void
339
+     */
340
+    public function putMany(array $items, string $namespace = '', int $batchSize = 100): void
341
+    {
342 342
     $chunks = array_chunk($items, $batchSize, true);
343 343
 
344 344
     foreach ($chunks as $chunk) {
345
-      foreach ($chunk as $key => $data) {
346
-          $this->putCache($data['cacheKey'], $data['cacheData'], $namespace);
345
+        foreach ($chunk as $key => $data) {
346
+            $this->putCache($data['cacheKey'], $data['cacheData'], $namespace);
347
+        }
347 348
         }
348
-      }
349 349
     $this->setMessage("{$this->getMessage()}", $this->isSuccess());
350 350
     $this->logger->debug("{$this->getMessage()} from Array driver.");
351
-  }
352
-
353
-  /**
354
-   * Renews the expiration time of a cache item.
355
-   * 
356
-   * @param string $cacheKey
357
-   * @param string|int $ttl
358
-   * @param string $namespace
359
-   * @return void
360
-   */
361
-  public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = ''): void
362
-  {
351
+    }
352
+
353
+    /**
354
+     * Renews the expiration time of a cache item.
355
+     * 
356
+     * @param string $cacheKey
357
+     * @param string|int $ttl
358
+     * @param string $namespace
359
+     * @return void
360
+     */
361
+    public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = ''): void
362
+    {
363 363
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
364 364
 
365 365
     if (isset($this->arrayStore[$arrayStoreKey])) {
@@ -367,78 +367,78 @@  discard block
 block discarded – undo
367 367
         $this->arrayStore[$arrayStoreKey]['expirationTime'] = time() + $ttlSeconds;
368 368
         $this->setMessage("cacheKey: {$cacheKey} renewed successfully", true);
369 369
         $this->logger->debug("{$this->getMessage()} from array driver.");
370
-      }
371
-  }
372
-
373
-  /**
374
-   * Sets a message and its success status.
375
-   * 
376
-   * @param string  $message
377
-   * @param boolean $success
378
-   * @return void
379
-   */
380
-  private function setMessage(string $message, bool $success): void
381
-  {
370
+        }
371
+    }
372
+
373
+    /**
374
+     * Sets a message and its success status.
375
+     * 
376
+     * @param string  $message
377
+     * @param boolean $success
378
+     * @return void
379
+     */
380
+    private function setMessage(string $message, bool $success): void
381
+    {
382 382
     $this->message = $message;
383 383
     $this->success = $success;
384
-  }
385
-
386
-  /**
387
-   * Serializes or unserializes data based on the flag.
388
-   * 
389
-   * @param mixed $data
390
-   * @param bool $serialize
391
-   * @return mixed
392
-   */
393
-  private function serialize(mixed $data, bool $serialize = true): mixed
394
-  {
384
+    }
385
+
386
+    /**
387
+     * Serializes or unserializes data based on the flag.
388
+     * 
389
+     * @param mixed $data
390
+     * @param bool $serialize
391
+     * @return mixed
392
+     */
393
+    private function serialize(mixed $data, bool $serialize = true): mixed
394
+    {
395 395
     return $serialize ? serialize($data) : unserialize($data);
396
-  }
397
-
398
-  /**
399
-   * Associates one or more keys to a tag.
400
-   *
401
-   * @param string $tag
402
-   * @param string ...$keys
403
-   * @return bool
404
-   */
405
-  public function tag(string $tag, string ...$keys): bool
406
-  {
396
+    }
397
+
398
+    /**
399
+     * Associates one or more keys to a tag.
400
+     *
401
+     * @param string $tag
402
+     * @param string ...$keys
403
+     * @return bool
404
+     */
405
+    public function tag(string $tag, string ...$keys): bool
406
+    {
407 407
     if (!isset($this->tags[$tag])) {
408
-      $this->tags[$tag] = [];
408
+        $this->tags[$tag] = [];
409 409
     }
410 410
     foreach ($keys as $key) {
411
-      // Accept either raw key or "namespace:key"
412
-      $arrayStoreKey = (str_contains($key, ':')) ? $key : $this->buildArrayKey($key, '');
413
-      $this->tags[$tag][$arrayStoreKey] = true;
411
+        // Accept either raw key or "namespace:key"
412
+        $arrayStoreKey = (str_contains($key, ':')) ? $key : $this->buildArrayKey($key, '');
413
+        $this->tags[$tag][$arrayStoreKey] = true;
414 414
     }
415 415
     $this->setMessage("Tagged successfully", true);
416 416
     $this->logger?->debug("{$this->getMessage()} from array driver.");
417 417
     return true;
418
-  }
419
-
420
-  /**
421
-   * Flushes all keys associated with a tag.
422
-   *
423
-   * @param string $tag
424
-   * @return void
425
-   */
426
-  public function flushTag(string $tag): void
427
-  {
418
+    }
419
+
420
+    /**
421
+     * Flushes all keys associated with a tag.
422
+     *
423
+     * @param string $tag
424
+     * @return void
425
+     */
426
+    public function flushTag(string $tag): void
427
+    {
428 428
     $keys = array_keys($this->tags[$tag] ?? []);
429 429
     foreach ($keys as $arrayStoreKey) {
430
-      // Recover original key/namespace combination
431
-      $parts = explode(':', $arrayStoreKey, 2);
432
-      if (count($parts) === 2) {
430
+        // Recover original key/namespace combination
431
+        $parts = explode(':', $arrayStoreKey, 2);
432
+        if (count($parts) === 2) {
433 433
         [$np, $key] = $parts;
434
-      } else {
434
+        } else {
435 435
         $np = '';
436 436
         $key = $arrayStoreKey;
437
-      }
438
-      $this->clearCache($key, $np);
437
+        }
438
+        $this->clearCache($key, $np);
439 439
     }
440 440
     unset($this->tags[$tag]);
441 441
     $this->setMessage("Tag flushed successfully", true);
442 442
     $this->logger?->debug("{$this->getMessage()} from array driver.");
443
-  }
443
+    }
444 444
 }
Please login to merge, or discard this patch.