PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.3
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.3
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / ai-authorization / domain / code-verifier.php

code-verifier.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.3, at src/ai-authorization/domain/code-verifier.php

65 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\AI_Authorization\Domain;
4
5 /**
6 * Class Code_Verifier representing a challenge code and its creation time.
7 * This is used during the authorization process to verify the user requesting a token.
8 */
9 class Code_Verifier {
10
11 /**
12 * The code.
13 *
14 * @var string
15 */
16 private $code;
17
18 /**
19 * The time the code was created.
20 *
21 * @var int
22 */
23 private $created_at;
24
25 /**
26 * Code_Verifier constructor.
27 *
28 * @param string $code The code.
29 * @param int $created_at The time the code was created.
30 */
31 public function __construct( string $code, int $created_at ) {
32 $this->code = $code;
33 $this->created_at = $created_at;
34 }
35
36 /**
37 * Get the code.
38 *
39 * @return string The code.
40 */
41 public function get_code(): string {
42 return $this->code;
43 }
44
45 /**
46 * Get the creation time of the code.
47 *
48 * @return int The creation time of the code.
49 */
50 public function get_created_at(): int {
51 return $this->created_at;
52 }
53
54 /**
55 * Check if the code is expired.
56 *
57 * @param int $validity_in_seconds The validity of the code in seconds.
58 *
59 * @return bool True if the code is expired, false otherwise.
60 */
61 public function is_expired( int $validity_in_seconds ): bool {
62 return $this->created_at < ( \time() - $validity_in_seconds );
63 }
64 }
65