|
@@ -6,7 +6,8 @@ if (!function_exists('make_tree')) {
|
|
|
* @param int $parentId
|
|
|
* @return array
|
|
|
*/
|
|
|
- function make_tree(array $list, $parentId = 0) {
|
|
|
+ function make_tree(array $list, $parentId = 0)
|
|
|
+ {
|
|
|
$tree = [];
|
|
|
if (empty($list)) {
|
|
|
return $tree;
|
|
@@ -34,14 +35,16 @@ if (!function_exists('text_diff')) {
|
|
|
{
|
|
|
$text1 = str_replace(' ', '', trim($text1));
|
|
|
$text2 = str_replace(' ', '', trim($text2));
|
|
|
- $w = explode("\n", $text1);
|
|
|
- $o = explode("\n", $text2);
|
|
|
- $w1 = array_diff_assoc($w,$o);
|
|
|
- $o1 = array_diff_assoc($o,$w);
|
|
|
+ $w = explode("\n", $text1);
|
|
|
+ $o = explode("\n", $text2);
|
|
|
+ $w1 = array_diff_assoc($w, $o);
|
|
|
+ $o1 = array_diff_assoc($o, $w);
|
|
|
$w2 = array();
|
|
|
$o2 = array();
|
|
|
- foreach($w1 as $idx => $val) $w2[sprintf("%03d<",$idx)] = sprintf("%03d- ", $idx+1) . "<del>" . trim($val) . "</del>";
|
|
|
- foreach($o1 as $idx => $val) $o2[sprintf("%03d>",$idx)] = sprintf("%03d+ ", $idx+1) . "<ins>" . trim($val) . "</ins>";
|
|
|
+ foreach ($w1 as $idx => $val)
|
|
|
+ $w2[sprintf("%03d<", $idx)] = sprintf("%03d- ", $idx + 1) . "<del>" . trim($val) . "</del>";
|
|
|
+ foreach ($o1 as $idx => $val)
|
|
|
+ $o2[sprintf("%03d>", $idx)] = sprintf("%03d+ ", $idx + 1) . "<ins>" . trim($val) . "</ins>";
|
|
|
$diff = array_merge($w2, $o2);
|
|
|
ksort($diff);
|
|
|
return implode("\n", $diff);
|
|
@@ -49,30 +52,40 @@ if (!function_exists('text_diff')) {
|
|
|
}
|
|
|
|
|
|
if (!function_exists('throw_validation_if')) {
|
|
|
- function throw_validation_if($condition, ...$parameters) {
|
|
|
+ function throw_validation_if($condition, ...$parameters)
|
|
|
+ {
|
|
|
return throw_if($condition, \App\Exceptions\ValidationException::class, ...$parameters);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!function_exists('make_array_list')) {
|
|
|
- function make_array_list(string $value):array {
|
|
|
- $array=[];
|
|
|
- if($value==''){
|
|
|
+ function make_array_list(string $value): array
|
|
|
+ {
|
|
|
+ $array = [];
|
|
|
+ if ($value == '') {
|
|
|
return $array;
|
|
|
}
|
|
|
$array = explode(',', $value);
|
|
|
|
|
|
- $array = array_filter($array, function($value) {
|
|
|
+ $array = array_filter($array, function ($value) {
|
|
|
return $value !== '';
|
|
|
});
|
|
|
|
|
|
- $array = array_map(function($value) {
|
|
|
+ $array = array_map(function ($value) {
|
|
|
return intval($value);
|
|
|
}, $array);
|
|
|
|
|
|
- return($array);
|
|
|
+ return ($array);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+if (!function_exists('json_decode_arr')) {
|
|
|
+ function json_decode_arr($string): array
|
|
|
+ {
|
|
|
+ $arr = json_decode($string, true);
|
|
|
+ if (is_null($arr)) {
|
|
|
+ $arr = [];
|
|
|
+ }
|
|
|
+ return $arr;
|
|
|
+ }
|
|
|
+}
|