'common.days.mon', self::TUESDAY => 'common.days.tues', self::WEDNESDAY => 'common.days.wed', self::THURSDAY => 'common.days.thurs', self::FRIDAY => 'common.days.fri', self::SATURDAY => 'common.days.sat', self::SUNDAY => 'common.days.sun', ]; public static $codes = [ 'M' => self::MONDAY, 'T' => self::TUESDAY, 'W' => self::WEDNESDAY, 'Th' => self::THURSDAY, 'F' => self::FRIDAY, 'S' => self::SATURDAY, 'Su' => self::SUNDAY, ]; /** * Map the ISO8601 numeric today to day */ public static $isoDayMap = [ 1 => self::MONDAY, 2 => self::TUESDAY, 3 => self::WEDNESDAY, 4 => self::THURSDAY, 5 => self::FRIDAY, 6 => self::SATURDAY, 7 => self::SUNDAY, ]; /** * Create the masked value for the days of week * * @param array $days * * @return int|mixed */ public static function getDaysMask(array $days) { $mask = 0; foreach ($days as $day) { $mask |= $day; } return $mask; } /** * See if the given mask has a day * * @param $mask * @param $day * * @return bool */ public static function in($mask, $day): bool { return in_mask($mask, $day); } /** * Does the mask contain today? * * @param $val * * @return bool */ public static function isToday($val): bool { return static::in($val, static::$isoDayMap[(int) date('N')]); } }