PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.0.3
Tableberg – Simple Gutenberg Table Block v1.0.3
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / renderer / utils.php

utils.php in Tableberg – Simple Gutenberg Table Block 1.0.3, at renderer/utils.php

49 lines 892 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Tableberg\Renderer;
4
5 /**
6 * @param mixed $value
7 * @return mixed|null
8 */
9 function getOrNull(&$value) {
10 return isset($value) ? $value : null;
11 }
12
13 /**
14 * @param mixed $value
15 * @return array<mixed>|null
16 */
17 function getArrayOrNull(&$value) {
18 $maybeValue = getOrNull($value);
19 return is_array($maybeValue) ? $maybeValue : null;
20 }
21
22 /**
23 * @param mixed $value
24 * @return string|null
25 */
26 function getStringOrNull(&$value) {
27 $maybeValue = getOrNull($value);
28 return is_string($maybeValue) ? $maybeValue : null;
29 }
30
31 /**
32 * @param mixed $value
33 * @return bool|null
34 */
35 function getBoolOrNull(&$value) {
36 $maybeValue = getOrNull($value);
37 return is_bool($maybeValue) ? $maybeValue : null;
38 }
39
40 /**
41 * @param float $value
42 * @param float $min
43 * @param float $max
44 * @return float
45 */
46 function clamp($value, $min, $max) {
47 return max($min, min($value, $max));
48 }
49