PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / trunk
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! vtrunk
3.8.0 3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 All 112 releases
templately / modules / utilities / Cleanup / RetentionKind.php

RetentionKind.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! trunk, at modules/utilities/Cleanup/RetentionKind.php

62 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * How a cleanup task decides what is expired.
4 *
5 * @package Templately
6 */
7
8 namespace Templately\Modules\Utilities\Cleanup;
9
10 /**
11 * Three kinds, because "expired" genuinely means three different things across
12 * the plugin's disposable data — and collapsing them into one age window is a
13 * defect, not a simplification:
14 *
15 * - AGE — untouched for longer than the ONE shared retention window.
16 * Import sessions, AI process records, and the working
17 * directories that belong to them. These already all used 7 days;
18 * sharing the window removes the possibility of future drift.
19 * - COUNT — keep the newest N, whatever their age. Import logs. An age rule
20 * here deletes the log of a week-old failure support is still
21 * investigating, and keeps two hundred from one busy afternoon.
22 * - INTRINSIC — the writer recorded an expiry on each item; honour that and
23 * ignore both the window and the count. Plugin cache entries, the
24 * cached pattern library, agent approval records. Applying the
25 * shared window here would delete cache the plugin still
26 * considers live — and the pattern library rebuilds over the
27 * network, so that costs real requests.
28 *
29 * Not a PHP 8.1 enum: this plugin supports PHP 7.4.
30 */
31 final class RetentionKind {
32
33 const AGE = 'age';
34 const COUNT = 'count';
35 const INTRINSIC = 'intrinsic';
36
37 /**
38 * @return string[]
39 */
40 public static function all(): array {
41 return [ self::AGE, self::COUNT, self::INTRINSIC ];
42 }
43
44 /**
45 * @param mixed $kind
46 * @return bool
47 */
48 public static function is_valid( $kind ): bool {
49 return is_string( $kind ) && in_array( $kind, self::all(), true );
50 }
51
52 /**
53 * Whether the shared age window applies to this kind.
54 *
55 * @param string $kind
56 * @return bool
57 */
58 public static function uses_age( string $kind ): bool {
59 return self::AGE === $kind;
60 }
61 }
62