PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.8
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.8
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 / promotions / domain / time-interval.php

time-interval.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.8, at src/promotions/domain/time-interval.php

72 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\Promotions\Domain;
4
5 /**
6 * Class Time_Interval
7 *
8 * Value object for a time interval.
9 */
10 class Time_Interval {
11
12 /**
13 * The starting time of the interval as a Unix timestamp.
14 *
15 * @var int
16 */
17 public $time_start;
18
19 /**
20 * The ending time of the interval as a Unix timestamp.
21 *
22 * @var int
23 */
24 public $time_end;
25
26 /**
27 * Time_Interval constructor.
28 *
29 * @codeCoverageIgnore
30 *
31 * @param int $time_start Interval start time.
32 * @param int $time_end Interval end time.
33 */
34 public function __construct( int $time_start, int $time_end ) {
35 $this->time_start = $time_start;
36 $this->time_end = $time_end;
37 }
38
39 /**
40 * Checks if the given time is within the interval.
41 *
42 * @param int $time The time to check.
43 *
44 * @return bool Whether the given time is within the interval.
45 */
46 public function contains( int $time ): bool {
47 return ( ( $time > $this->time_start ) && ( $time < $this->time_end ) );
48 }
49
50 /**
51 * Sets the interval astarting date.
52 *
53 * @param int $time_start The interval start time.
54 *
55 * @return void
56 */
57 public function set_start_date( int $time_start ) {
58 $this->time_start = $time_start;
59 }
60
61 /**
62 * Sets the interval ending date.
63 *
64 * @param int $time_end The interval end time.
65 *
66 * @return void
67 */
68 public function set_end_date( int $time_end ) {
69 $this->time_end = $time_end;
70 }
71 }
72