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 / Support / Validation / Rules / InRule.php

InRule.php in Metricool – Social media and site statistics trunk, at app/Support/Validation/Rules/InRule.php

25 lines 594 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\Support\Validation\Rules;
6
7 class InRule extends AbstractRule
8 {
9 /**
10 * Checks if the field value is one of the given parameters,
11 * e.g. "in:countries,referers".
12 * @inheritDoc
13 */
14 public function validate(string $field, $value, array $data): void
15 {
16 if (!in_array((string) $value, $this->parameters, true)) {
17 $this->fail(sprintf(
18 /* translators: %s is the field name */
19 __('%s is invalid.', 'metricool'),
20 $field
21 ));
22 }
23 }
24 }
25