Language: Use type hint instead of manual type check
authorFomafix <fomafix@googlemail.com>
Wed, 3 Apr 2019 16:38:55 +0000 (18:38 +0200)
committerFomafix <fomafix@googlemail.com>
Wed, 3 Apr 2019 16:39:45 +0000 (18:39 +0200)
Change-Id: I9c68d0838d5865c29bff85b9a6bf50e02e83f556

languages/Language.php

index 9ed67f9..f72ac1a 100644 (file)
@@ -3556,12 +3556,8 @@ class Language {
         * @return string
         */
        private function truncateInternal(
         * @return string
         */
        private function truncateInternal(
-               $string, $length, $ellipsis, $adjustLength, $measureLength, $getSubstring
+               $string, $length, $ellipsis, $adjustLength, callable $measureLength, callable $getSubstring
        ) {
        ) {
-               if ( !is_callable( $measureLength ) || !is_callable( $getSubstring ) ) {
-                       throw new InvalidArgumentException( 'Invalid callback provided' );
-               }
-
                # Check if there is no need to truncate
                if ( $measureLength( $string ) <= abs( $length ) ) {
                        return $string; // no need to truncate
                # Check if there is no need to truncate
                if ( $measureLength( $string ) <= abs( $length ) ) {
                        return $string; // no need to truncate