Passed
Pull Request — main (#61)
by Sílvio
02:56
created
tests/Unit/DatabaseOptionBuilderTTLAndFlushTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
 
8 8
 class DatabaseOptionBuilderTTLAndFlushTest extends TestCase
9 9
 {
10
-  private string $table = 'cache_items_ttl_flush';
10
+    private string $table = 'cache_items_ttl_flush';
11 11
 
12
-  protected function setUp(): void
13
-  {
12
+    protected function setUp(): void
13
+    {
14 14
     // Ensure the custom table exists (SQLite-compatible DDL)
15 15
     $pdo = Silviooosilva\CacheerPhp\Core\Connect::getInstance();
16 16
     $pdo->exec("CREATE TABLE IF NOT EXISTS {$this->table} (
@@ -27,25 +27,25 @@  discard block
 block discarded – undo
27 27
     CREATE INDEX IF NOT EXISTS idx_{$this->table}_expirationTime ON {$this->table} (expirationTime);
28 28
     CREATE INDEX IF NOT EXISTS idx_{$this->table}_key_namespace ON {$this->table} (cacheKey, cacheNamespace);
29 29
     ");
30
-  }
30
+    }
31 31
 
32
-  protected function tearDown(): void
33
-  {
32
+    protected function tearDown(): void
33
+    {
34 34
     // clean up flush file
35 35
     $path = FlushHelper::pathFor('db', $this->table);
36 36
     if (file_exists($path)) {
37
-      @unlink($path);
37
+        @unlink($path);
38 38
     }
39 39
     $pdo = Silviooosilva\CacheerPhp\Core\Connect::getInstance();
40 40
     $pdo->exec("DROP TABLE IF EXISTS {$this->table}");
41
-  }
41
+    }
42 42
 
43
-  public function test_expiration_time_from_options_sets_default_ttl()
44
-  {
43
+    public function test_expiration_time_from_options_sets_default_ttl()
44
+    {
45 45
     $options = OptionBuilder::forDatabase()
46
-      ->table($this->table)
47
-      ->expirationTime('-1 seconds')
48
-      ->build();
46
+        ->table($this->table)
47
+        ->expirationTime('-1 seconds')
48
+        ->build();
49 49
 
50 50
     $cache = new Cacheer($options);
51 51
     $cache->setDriver()->useDatabaseDriver();
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
64 64
     $this->assertNotFalse($row);
65 65
     $this->assertLessThanOrEqual(time(), strtotime($row['expirationTime']));
66
-  }
66
+    }
67 67
 
68
-  public function test_flush_after_from_options_triggers_auto_flush()
69
-  {
68
+    public function test_flush_after_from_options_triggers_auto_flush()
69
+    {
70 70
     $options = OptionBuilder::forDatabase()
71
-      ->table($this->table)
72
-      ->flushAfter('1 seconds')
73
-      ->build();
71
+        ->table($this->table)
72
+        ->flushAfter('1 seconds')
73
+        ->build();
74 74
 
75 75
     // Pre-create an old last flush file to force a flush on init
76 76
     $flushFile = FlushHelper::pathFor('db', $this->table);
@@ -87,5 +87,5 @@  discard block
 block discarded – undo
87 87
     $cache->setDriver()->useDatabaseDriver();
88 88
 
89 89
     $this->assertEmpty($cache->getAll());
90
-  }
90
+    }
91 91
 }
Please login to merge, or discard this patch.
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.