Skip to content

Commit 546df8f

Browse files
committed
update: add more unit for filters
1 parent 12dafde commit 546df8f

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/Filter/Filters.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -610,32 +610,31 @@ public static function fullSpecialChars($val, int $flags = 0): string
610610
/**
611611
* 字符串长度过滤截取
612612
*
613-
* @param string $string 字符串
614-
* @param integer $start 起始长度
615-
* @param int $end 结束位置
613+
* @param string $string
614+
* @param integer $start
615+
* @param int $length
616616
*
617617
* @return string
618618
*/
619-
public static function stringCute($string, $start = 0, $end = null): string
619+
public static function stringCute($string, $start = 0, $length = 0): string
620620
{
621621
if (!is_string($string)) {
622622
return '';
623623
}
624624

625-
// $length = Helper::strlen($string);
626-
return self::subStr($string, $start, $end);
625+
return self::subStr($string, (int)$start, (int)$length);
627626
}
628627

629628
/**
630629
* @param string $string
631630
* @param int $start
632-
* @param null $end
631+
* @param int $length
633632
*
634633
* @return string
635634
*/
636-
public static function cut($string, $start = 0, $end = null): string
635+
public static function cut($string, $start = 0, $length = 0): string
637636
{
638-
return self::stringCute($string, $start, $end);
637+
return self::stringCute($string, $start, $length);
639638
}
640639

641640
/**

src/Helper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ public static function getMimeType(string $file): string
109109
}
110110

111111
if (function_exists('mime_content_type')) {
112+
/** @noinspection PhpComposerExtensionStubsInspection */
112113
return mime_content_type($file);
113114
}
114115

115116
if (function_exists('finfo_file')) {
117+
/** @noinspection PhpComposerExtensionStubsInspection */
116118
return (string)finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file);
117119
}
118120

0 commit comments

Comments
 (0)