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

Yoast / wordpress-seo / 6078396534

04 Sep 2023 11:31PM UTC coverage: 45.745% (-0.03%) from 45.771%
6078396534

Pull #20620

github

web-flow
Merge b27c83eed into 773e21dd7
Pull Request #20620: Add black friday checklist promotion in product editor

0 of 12 new or added lines in 3 files covered. (0.0%)

549 existing lines in 1 file now uncovered.

12149 of 26558 relevant lines covered (45.75%)

3.38 hits per line

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

50.0
/src/promotions/application/promotion-manager.php
1
<?php
2

3
namespace Yoast\WP\SEO\Promotions\Application;
4

5
use Yoast\WP\SEO\Promotions\Domain\Promotion_Interface;
6

7
/**
8
 * Class to manage promotional promotions.
9
 *
10
 * @makePublic
11
 */
12
class Promotion_Manager implements Promotion_Manager_Interface {
13

14
        /**
15
         * The centralized list of promotions: all promotions should be passed to the constructor.
16
         *
17
         * @var array<Abstract_Promotion>
18
         */
19
        private $promotions_list = [];
20

21
        /**
22
         * Class constructor.
23
         *
24
         * @param Promotion_Interface ...$promotions list of promotions.
25
         */
26
        public function __construct( Promotion_Interface ...$promotions ) {
27
                $this->promotions_list = $promotions;
×
28
        }
29

30
        /**
31
         * Whether the promotion is effective.
32
         *
33
         * @param string $promotion_name The name of the promotion.
34
         *
35
         * @return bool Whether the promotion is effective.
36
         */
37
        public function is( string $promotion_name ) : bool {
38
                $time = \time();
2✔
39

40
                foreach ( $this->promotions_list as $promotion ) {
2✔
41
                        if ( $promotion->get_promotion_name() === $promotion_name ) {
2✔
42
                                return $promotion->get_time_interval()->contains( $time );
2✔
43
                        }
44
                }
45

46
                return false;
2✔
47
        }
48

49
        /**
50
         * Get the list of promotions.
51
         *
52
         * @return array<Abstract_Promotion> The list of promotions.
53
         */
54
        public function get_promotions_list() : array {
55
                return $this->promotions_list;
2✔
56
        }
57

58
        /**
59
         * Getthe names of currently active promotions.
60
         *
61
         * @return array<string> The list of promotions.
62
         */
63
        public function get_current_promotions() : array {
NEW
64
                $current_promotions = [];
×
65

NEW
66
                foreach ( $this->promotions_list as $promotion ) {
×
NEW
67
                        if ( $promotion->get_time_interval()->contains( \time() ) ) {
×
NEW
68
                                $current_promotions[] = $promotion->get_promotion_name();
×
69
                        }
70
                }
71

NEW
72
                return $current_promotions;
×
73
        }
74
}
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

© 2025 Coveralls, Inc