PluginProbe
Metricool – Social media and site statistics / 2.1.1
Metricool – Social media and site statistics v2.1.1
2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
metricool / app / Support / Validation / Rules / MinRule.php

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

29 lines 778 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 MinRule extends AbstractRule
8 {
9 /**
10 * Checks if the size of the field is at least the given minimum. Uses the
11 * numeric value for numbers, the length for strings and the count for
12 * arrays.
13 * @inheritDoc
14 */
15 public function validate(string $field, $value, array $data): void
16 {
17 $min = (float) ($this->parameters[0] ?? 0);
18
19 if ($this->sizeOf($value) < $min) {
20 $this->fail(sprintf(
21 /* translators: %1$s is the field name, %2$s is the minimum size */
22 __('%1$s must be at least %2$s.', 'metricool'),
23 $field,
24 $this->parameters[0] ?? '0'
25 ));
26 }
27 }
28 }
29