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

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