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 / BooleanRule.php

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

24 lines 586 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 BooleanRule extends AbstractRule
8 {
9 /**
10 * Checks if the field contains a boolean-like value.
11 * @inheritDoc
12 */
13 public function validate(string $field, $value, array $data): void
14 {
15 if (!in_array($value, [true, false, 0, 1, '0', '1', 'true', 'false'], true)) {
16 $this->fail(sprintf(
17 /* translators: %s is the field name */
18 __('%s must be true or false.', 'metricool'),
19 $field
20 ));
21 }
22 }
23 }
24