Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../src/promotio.../applicat...
File: promotion-manager.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Promotions\Application;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Promotions\Domain\Promotion_Interface;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Class to manage promotional promotions.
[7] Fix | Delete
*
[8] Fix | Delete
* @makePublic
[9] Fix | Delete
*/
[10] Fix | Delete
class Promotion_Manager implements Promotion_Manager_Interface {
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* The centralized list of promotions: all promotions should be passed to the constructor.
[14] Fix | Delete
*
[15] Fix | Delete
* @var array<Abstract_Promotion>
[16] Fix | Delete
*/
[17] Fix | Delete
private $promotions_list = [];
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Class constructor.
[21] Fix | Delete
*
[22] Fix | Delete
* @param Promotion_Interface ...$promotions List of promotions.
[23] Fix | Delete
*/
[24] Fix | Delete
public function __construct( Promotion_Interface ...$promotions ) {
[25] Fix | Delete
$this->promotions_list = $promotions;
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Whether the promotion is effective.
[30] Fix | Delete
*
[31] Fix | Delete
* @param string $promotion_name The name of the promotion.
[32] Fix | Delete
*
[33] Fix | Delete
* @return bool Whether the promotion is effective.
[34] Fix | Delete
*/
[35] Fix | Delete
public function is( string $promotion_name ): bool {
[36] Fix | Delete
$time = \time();
[37] Fix | Delete
[38] Fix | Delete
foreach ( $this->promotions_list as $promotion ) {
[39] Fix | Delete
if ( $promotion->get_promotion_name() === $promotion_name ) {
[40] Fix | Delete
return $promotion->get_time_interval()->contains( $time );
[41] Fix | Delete
}
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
return false;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Get the list of promotions.
[49] Fix | Delete
*
[50] Fix | Delete
* @return array<Abstract_Promotion> The list of promotions.
[51] Fix | Delete
*/
[52] Fix | Delete
public function get_promotions_list(): array {
[53] Fix | Delete
return $this->promotions_list;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Get the names of currently active promotions.
[58] Fix | Delete
*
[59] Fix | Delete
* @return array<string> The list of promotions.
[60] Fix | Delete
*/
[61] Fix | Delete
public function get_current_promotions(): array {
[62] Fix | Delete
$current_promotions = [];
[63] Fix | Delete
$time = \time();
[64] Fix | Delete
foreach ( $this->promotions_list as $promotion ) {
[65] Fix | Delete
if ( $promotion->get_time_interval()->contains( $time ) ) {
[66] Fix | Delete
$current_promotions[] = $promotion->get_promotion_name();
[67] Fix | Delete
}
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
return $current_promotions;
[71] Fix | Delete
}
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function