Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
params.php
1<?php
2
3namespace Bitrix\Main\Grid;
4
5
6class Params
7{
15 public static function prepareBoolean(array $values, $defaultValue)
16 {
17 $value = $defaultValue;
18
19 foreach ($values as $item)
20 {
21 if (is_bool($item))
22 {
23 $value = $item;
24 break;
25 }
26 }
27
28 return $value;
29 }
30
31
39 public static function prepareString(array $values, $defaultValue)
40 {
41 $value = $defaultValue;
42
43 foreach ($values as $item)
44 {
45 if (is_string($item))
46 {
47 $value = $item;
48 break;
49 }
50 }
51
52 return $value;
53 }
54
55
63 public static function prepareArray(array $values, $defaultValue)
64 {
65 $value = $defaultValue;
66
67 foreach ($values as $item)
68 {
69 if (is_array($item))
70 {
71 $value = $item;
72 break;
73 }
74 }
75
76 return $value;
77 }
78
79
87 public static function prepareInt(array $values, $defaultValue)
88 {
89 $value = $defaultValue;
90
91 foreach ($values as $item)
92 {
93 if (is_numeric($item))
94 {
95 $value = $item;
96 break;
97 }
98 }
99
100 return $value;
101 }
102
103 public static function ensureString(array $params, $name)
104 {
105 return isset($params[$name]) && is_string($params[$name]);
106 }
107
108 public static function ensureNotEmptyString(array $params, $name)
109 {
110 return isset($params[$name]) && is_string($params[$name]) && $params[$name] !== "";
111 }
112
113 public static function ensureArray(array $params, $name)
114 {
115 return isset($params[$name]) && is_array($params[$name]);
116 }
117
118 public static function ensureNotEmptyArray(array $params, $name)
119 {
120 return isset($params[$name]) && is_array($params[$name]) && !empty($params[$name]);
121 }
122}
static ensureArray(array $params, $name)
Definition params.php:113
static ensureNotEmptyString(array $params, $name)
Definition params.php:108
static ensureNotEmptyArray(array $params, $name)
Definition params.php:118
static prepareString(array $values, $defaultValue)
Definition params.php:39
static prepareBoolean(array $values, $defaultValue)
Definition params.php:15
static ensureString(array $params, $name)
Definition params.php:103
static prepareInt(array $values, $defaultValue)
Definition params.php:87
static prepareArray(array $values, $defaultValue)
Definition params.php:63