@@ -213,8 +213,8 @@ function parse_attr(string $value = '')
213213 if (strpos ($ value , ': ' )) {
214214 $ value = [];
215215 foreach ($ array as $ val ) {
216- [$ k , $ v ] = explode (': ' , $ val );
217- $ value [$ k ] = $ v ;
216+ [$ k , $ v ] = explode (': ' , $ val );
217+ $ value [$ k ] = $ v ;
218218 }
219219 } else {
220220 $ value = $ array ;
@@ -261,7 +261,7 @@ function human_date($time, $local = null)
261261 * @param string $delimiter 数字和单位分隔符
262262 * @return string 格式化后的带单位的大小
263263 */
264- function format_bytes (float | int $ size , string $ delimiter = '' ): string
264+ function format_bytes (float | int $ size , string $ delimiter = '' ): string
265265 {
266266 $ units = ['B ' , 'KB ' , 'MB ' , 'GB ' , 'TB ' , 'PB ' ];
267267 for ($ i = 0 ; $ size >= 1024 && $ i < 5 ; $ i ++) {
@@ -334,38 +334,6 @@ function genRandomString(int $len = 6): string
334334 }
335335}
336336
337- if (!function_exists ('getModel ' )) {
338- /**
339- * 获取模型数据
340- * @param type $modelid 模型ID
341- * @param type $name 返回的字段,默认返回全部,数组
342- * @return boolean
343- */
344- function getModel ($ modelid , $ name = '' )
345- {
346- if (empty ($ modelid ) || !is_numeric ($ modelid )) {
347- return false ;
348- }
349- $ key = 'getModel_ ' . $ modelid ;
350- /* 读取缓存数据 */
351- $ cache = Cache::get ($ key );
352- if ($ cache === 'false ' ) {
353- return false ;
354- }
355- if (empty ($ cache )) {
356- //读取数据
357- $ cache = Db::name ('Model ' )->find ($ modelid );
358- if (empty ($ cache )) {
359- Cache::set ($ key , 'false ' , 60 );
360- return false ;
361- } else {
362- Cache::set ($ key , $ cache , 3600 );
363- }
364- }
365- return is_null ($ name ) ? $ cache : $ cache [$ name ];
366- }
367- }
368-
369337if (!function_exists ('http_down ' )) {
370338 /**
371339 * 下载远程文件,默认保存在temp下
@@ -564,8 +532,8 @@ function hsv2rgb($h, $s, $v): array
564532 */
565533 function letter_avatar (string $ text ): string
566534 {
567- $ total = unpack ('L ' , hash ('adler32 ' , $ text , true ))[1 ];
568- $ hue = $ total % 360 ;
535+ $ total = unpack ('L ' , hash ('adler32 ' , $ text , true ))[1 ];
536+ $ hue = $ total % 360 ;
569537 [$ r , $ g , $ b ] = hsv2rgb ($ hue / 360 , 0.3 , 0.9 );
570538
571539 $ bg = "rgb( {$ r }, {$ g }, {$ b }) " ;
@@ -583,11 +551,11 @@ function letter_avatar(string $text): string
583551 * @param ?string $background 背景颜色
584552 * @return string
585553 */
586- function build_suffix_image (string $ suffix , string $ background = null ): string
554+ function build_suffix_image (string $ suffix , ? string $ background = null ): string
587555 {
588- $ suffix = mb_substr (strtoupper ($ suffix ), 0 , 4 );
589- $ total = unpack ('L ' , hash ('adler32 ' , $ suffix , true ))[1 ];
590- $ hue = $ total % 360 ;
556+ $ suffix = mb_substr (strtoupper ($ suffix ), 0 , 4 );
557+ $ total = unpack ('L ' , hash ('adler32 ' , $ suffix , true ))[1 ];
558+ $ hue = $ total % 360 ;
591559 [$ r , $ g , $ b ] = hsv2rgb ($ hue / 360 , 0.3 , 0.9 );
592560
593561 $ background = $ background ?: "rgb( {$ r }, {$ g }, {$ b }) " ;
@@ -644,7 +612,7 @@ function check_cors_request()
644612 * @param bool $is_image
645613 * @return bool|string|string[]
646614 */
647- function xss_clean (array | string $ content , bool $ is_image = false )
615+ function xss_clean (array | string $ content , bool $ is_image = false )
648616 {
649617 return \app \common \library \Security::instance ()->xss_clean ($ content , $ is_image );
650618 }
0 commit comments