PluginProbe
Metricool – Social media and site statistics / trunk
Metricool – Social media and site statistics vtrunk
2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
metricool / app / Features / UserSettings / Rules / TimezoneRule.php

TimezoneRule.php in Metricool – Social media and site statistics trunk, at app/Features/UserSettings/Rules/TimezoneRule.php

30 lines 746 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Metricool\Features\UserSettings\Rules;
6
7 use Metricool\Support\Validation\Rules\AbstractRule;
8
9 class TimezoneRule extends AbstractRule
10 {
11 /**
12 * Checks if the value is a valid timezone identifier
13 * @inheritDoc
14 */
15 public function validate(string $field, $value, array $data): void
16 {
17 $validTimezones = timezone_identifiers_list();
18
19 if (!in_array($value, $validTimezones)) {
20 $this->fail(esc_html(
21 sprintf(
22 // translators: %s is the invalid timezone submitted by the user.
23 __('%s is not a valid timezone', 'metricool'),
24 $value
25 )
26 ));
27 }
28 }
29 }
30