• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / whip / 6985375056

24 Nov 2023 10:53PM UTC coverage: 28.713% (+1.2%) from 27.5%
6985375056

push

github

web-flow
Merge pull request #152 from Yoast/JRF/ghactions-switch-to-coveralls-reporter

GH Actions: switch to Coveralls action runner to upload reports

87 of 303 relevant lines covered (28.71%)

2.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/Whip_MessageDismisser.php
1
<?php
2
/**
3
 * WHIP libary file.
4
 *
5
 * @package Yoast\WHIP
6
 */
7

8
/**
9
 * A class to dismiss messages.
10
 */
11
class Whip_MessageDismisser {
12

13
        /**
14
         * Storage object to manage the dismissal state.
15
         *
16
         * @var Whip_DismissStorage
17
         */
18
        protected $storage;
19

20
        /**
21
         * The current time.
22
         *
23
         * @var int
24
         */
25
        protected $currentTime;
26

27
        /**
28
         * The number of seconds the message will be dismissed.
29
         *
30
         * @var int
31
         */
32
        protected $threshold;
33

34
        /**
35
         * Whip_MessageDismisser constructor.
36
         *
37
         * @param int                 $currentTime The current time.
38
         * @param int                 $threshold   The number of seconds the message will be dismissed.
39
         * @param Whip_DismissStorage $storage     Storage object to manage the dismissal state.
40
         */
41
        public function __construct( $currentTime, $threshold, Whip_DismissStorage $storage ) {
15✔
42
                $this->currentTime = $currentTime;
15✔
43
                $this->threshold   = $threshold;
15✔
44
                $this->storage     = $storage;
15✔
45
        }
10✔
46

47
        /**
48
         * Saves the version number to the storage to indicate the message as being dismissed.
49
         *
50
         * @return void
51
         */
52
        public function dismiss() {
3✔
53
                $this->storage->set( $this->currentTime );
3✔
54
        }
2✔
55

56
        /**
57
         * Checks if the current time is lower than the stored time extended by the threshold.
58
         *
59
         * @return bool True when current time is lower than stored value + threshold.
60
         */
61
        public function isDismissed() {
12✔
62
                return ( $this->currentTime <= ( $this->storage->get() + $this->threshold ) );
12✔
63
        }
64

65
        /**
66
         * Checks the nonce.
67
         *
68
         * @param string $nonce  The nonce to check.
69
         * @param string $action The action to check.
70
         *
71
         * @return bool True when the nonce is valid.
72
         */
73
        public function verifyNonce( $nonce, $action ) {
×
74
                return (bool) wp_verify_nonce( $nonce, $action );
×
75
        }
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc