<?php
|
namespace JVBase\managers\SEO\render\Traits\_Properties;
|
|
use JVBase\managers\SEO\render\Traits\_Helpers\arrayHelper;
|
|
if (!defined('ABSPATH')) {
|
exit;
|
}
|
trait byMonthTrait {
|
use arrayHelper;
|
/**
|
* @var int|array Defines the month(s) of the year on which a recurring Event takes place. Specified as an Integer between 1-12. January is 1.
|
*/
|
protected int|array $byMonth;
|
|
public function getByMonth():int|array|null
|
{
|
return $this->byMonth??null;
|
}
|
public function setByMonth(int|array $byMonth):void
|
{
|
if (is_array($byMonth)) {
|
$byMonth = $this->intArray('byMonth', $byMonth);
|
} else {
|
$byMonth = [$byMonth];
|
}
|
$byMonth = array_filter($byMonth,
|
function($month) {
|
if ($month === 0 || $month > 12) {
|
error_log('[SEO] Invalid month number: '.$month);
|
return false;
|
}
|
return true;
|
});
|
if (empty($byMonth)){
|
error_log('[SEO]No byMonth values remaining');
|
return;
|
}
|
if (count($byMonth) === 1) {
|
$byMonth = $byMonth[0];
|
}
|
|
if ($byMonth === 0 || $byMonth > 12) {
|
error_log('[SEO] Invalid month number: '.$byMonth);
|
return;
|
}
|
$this->byMonth = $byMonth;
|
}
|
}
|