PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.6.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.6.0
5.6.0 5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 3.0.72 All 35 releases
double-opt-in / src / FollowUp / FollowUpRecord.php

FollowUpRecord.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 5.6.0, at src/FollowUp/FollowUpRecord.php

169 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * One persisted follow-up action row.
4 *
5 * @package Forge12\DoubleOptIn\FollowUp
6 * @since 5.6.0
7 */
8
9 declare( strict_types=1 );
10
11 namespace Forge12\DoubleOptIn\FollowUp;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Plain data holder for a row of `{prefix}f12_cf7_doubleoptin_followup`.
19 * Times are UTC `Y-m-d H:i:s` strings or '' when unset.
20 */
21 final class FollowUpRecord {
22
23 /** @var int */
24 public $id = 0;
25
26 /** @var int */
27 public $optInId = 0;
28
29 /** @var string */
30 public $integration = '';
31
32 /** @var string */
33 public $actionId = '';
34
35 /** @var string */
36 public $actionKind = '';
37
38 /** @var string */
39 public $actionLabel = '';
40
41 /** @var string */
42 public $fingerprint = '';
43
44 /** @var string */
45 public $status = FollowUpStatus::PENDING;
46
47 /** @var int */
48 public $attempts = 0;
49
50 /**
51 * Attempts since the last manual retry — what the automatic backoff
52 * counts. `attempts` counts every attempt ever made.
53 *
54 * @var int
55 */
56 public $budgetAttempts = 0;
57
58 /** @var string */
59 public $attemptId = '';
60
61 /** @var string */
62 public $trigger = '';
63
64 /** @var string */
65 public $startedAt = '';
66
67 /** @var string */
68 public $finishedAt = '';
69
70 /** @var string */
71 public $nextAttemptAt = '';
72
73 /** @var string */
74 public $leaseUntil = '';
75
76 /** @var string */
77 public $errorCode = '';
78
79 /** @var bool */
80 public $retryable = false;
81
82 /** @var int */
83 public $httpStatus = 0;
84
85 /** @var string */
86 public $responseKind = '';
87
88 /** @var string */
89 public $entryRef = '';
90
91 /** @var string */
92 public $evidence = '';
93
94 /** @var string */
95 public $createdAt = '';
96
97 /**
98 * Hydrate from a database row (ARRAY_A).
99 *
100 * @param array<string, mixed> $row
101 */
102 public static function fromRow( array $row ): self {
103 $r = new self();
104 $r->id = (int) ( $row['id'] ?? 0 );
105 $r->optInId = (int) ( $row['optin_id'] ?? 0 );
106 $r->integration = (string) ( $row['integration'] ?? '' );
107 $r->actionId = (string) ( $row['action_id'] ?? '' );
108 $r->actionKind = (string) ( $row['action_kind'] ?? '' );
109 $r->actionLabel = (string) ( $row['action_label'] ?? '' );
110 $r->fingerprint = (string) ( $row['config_fingerprint'] ?? '' );
111 $r->status = (string) ( $row['status'] ?? FollowUpStatus::PENDING );
112 $r->attempts = (int) ( $row['attempts'] ?? 0 );
113 $r->budgetAttempts = (int) ( $row['budget_attempts'] ?? 0 );
114 $r->attemptId = (string) ( $row['attempt_id'] ?? '' );
115 $r->trigger = (string) ( $row['attempt_trigger'] ?? '' );
116 $r->startedAt = (string) ( $row['started_at'] ?? '' );
117 $r->finishedAt = (string) ( $row['finished_at'] ?? '' );
118 $r->nextAttemptAt = (string) ( $row['next_attempt_at'] ?? '' );
119 $r->leaseUntil = (string) ( $row['lease_until'] ?? '' );
120 $r->errorCode = (string) ( $row['error_code'] ?? '' );
121 $r->retryable = ! empty( $row['retryable'] );
122 $r->httpStatus = (int) ( $row['http_status'] ?? 0 );
123 $r->responseKind = (string) ( $row['response_kind'] ?? '' );
124 $r->entryRef = (string) ( $row['entry_ref'] ?? '' );
125 $r->evidence = (string) ( $row['evidence'] ?? '' );
126 $r->createdAt = (string) ( $row['created_at'] ?? '' );
127 return $r;
128 }
129
130 /**
131 * Admin/REST representation. Contains no personal data by
132 * construction — every field is structural.
133 *
134 * @return array<string, mixed>
135 */
136 public function toArray(): array {
137 return array(
138 'id' => $this->id,
139 'optin_id' => $this->optInId,
140 'integration' => $this->integration,
141 'action_id' => $this->actionId,
142 'action_kind' => $this->actionKind,
143 'action_label' => $this->actionLabel,
144 'status' => $this->status,
145 'attempts' => $this->attempts,
146 'budget_attempts' => $this->budgetAttempts,
147 'attempt_id' => $this->attemptId,
148 'trigger' => $this->trigger,
149 'started_at' => $this->startedAt,
150 'finished_at' => $this->finishedAt,
151 'next_attempt_at' => $this->nextAttemptAt,
152 'error_code' => $this->errorCode,
153 'retryable' => $this->retryable,
154 'http_status' => $this->httpStatus,
155 'response_kind' => $this->responseKind,
156 'entry_ref' => $this->entryRef,
157 'evidence' => $this->evidence,
158 'created_at' => $this->createdAt,
159 );
160 }
161
162 /**
163 * Rebuild the action descriptor this row was planned from.
164 */
165 public function toAction(): FollowUpAction {
166 return new FollowUpAction( $this->actionId, $this->actionKind, $this->actionLabel, true, '', $this->entryRef );
167 }
168 }
169