diff --git a/Link.php b/Link.php new file mode 100644 index 0000000..16b0820 --- /dev/null +++ b/Link.php @@ -0,0 +1,25 @@ + + * + * @param String $string + * + * @return String + */ + public static function asciiEscString( $string ) { + $return = ''; + foreach ( str_split( $string ) as $char ) { + $return .= '&#' . ord( $char ) . ';'; + } + + return $return; + } +} diff --git a/Text.php b/Text.php new file mode 100644 index 0000000..4b1442f --- /dev/null +++ b/Text.php @@ -0,0 +1,50 @@ + $string_length ) { + $start = $string_length; + } + + if ( $length < 0 ) { + $length = max( 0, $string_length - $start + $length ); + } else if ( ( is_null( $length ) === true ) || ( $length > $string_length ) ) { + $length = $string_length; + } + + if ( ( $start + $length ) > $string_length ) { + $length = $string_length - $start; + } + + if ( is_null( $encoding ) === true ) { + return mb_substr( $string, 0, $start ) . $replacement . mb_substr( $string, $start + $length, + $string_length - $start - $length ); + } + + return mb_substr( $string, 0, $start, $encoding ) . $replacement . mb_substr( $string, $start + $length, + $string_length - $start - $length, $encoding ); + } + + return ( is_null( $length ) === true ) ? substr_replace( $string, $replacement, + $start ) : substr_replace( $string, $replacement, $start, $length ); + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..f1b92b9 --- /dev/null +++ b/composer.json @@ -0,0 +1,17 @@ +{ + "name": "onvardgmbh/helper-classes", + "description": "PHP Helper Classes for often used functions", + "license": "MIT", + "authors": [ + { + "name": "Björn Hasse", + "email": "hasse@onvard.de" + } + ], + "require": {}, + "autoload": { + "psr-4": { + "Onvardgmbh\\HelperClasses\\": "/" + } + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e69de29