Returns information if the string ends with given ending / characters

@param string $string String to check
@param string $ending The ending of string, one or more characters
@return bool
514093
public static function endsWith($string, $ending)
    {
        if (1 === strlen($ending) && !self::isLetterOrDigit($ending)) {
            $ending = '\\' . $ending;
        }

        return (bool)preg_match('|' . $ending . '$|', $string);
    }
908290
public static function endsWith($string, $substrings)
    {
        if (is_array($substrings)) {
            foreach ((array) $substrings as $substring) {
                if ((string) $substring === static::subString($string, -static::length($substring))) {
                    return true;
                }
            }
        } elseif (is_string($substrings)) {
            if ((string) $substring === static::subString($string, -static::length($substring))) {
                return true;
            }
        }

        return false;
    }
35551
public static function endsWith($string, $look)
    {
        return strrpos($string, $look) === strlen($string) - strlen($look);
    }
875256
public function truncate($string, $endlength="30", $end="...")
        {
            $strlen = strlen($string);

            if ($strlen > $endlength) {
                $trim = $endlength - $strlen;
                $string = substr($string, 0, $trim);
                $string .= $end;
            }

            return $string;
        }
479956
private function endswith($string, $test)
    {
        $strlen = strlen($string);
        $testlen = strlen($test);
        if ($testlen > $strlen) {
            return false;
        }

        return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
    }
154180
private function readStreamTill($ending)
    {
        $buffer = '';
        $len = strlen($ending);
        do {
            $char = fread($this->stream, 1);
            $buffer .= $char;
        } while ($char && substr($buffer, $len * -1) != $ending && !feof($this->stream));
        return $buffer;
    }
344770
public static function endsWith($string, $target, $caseSensitive = true)
    {
        $stringLength = Utf8String::strlen($string);
        $targetLength = Utf8String::strlen($target);

        if ($stringLength < $targetLength) {
            return false;
        }

        if (!$caseSensitive) {
            $string = strtolower($string);
            $target = strtolower($target);
        }

        $end = Utf8String::substr($string, -$targetLength);

        return $end === $target;
    }
563035
private function isRegex(string $string): bool
    {
        if (preg_match('/^(.{3,}?)['.self::ALLOWED_MODIFIERS.']*$/', $string, $m)) {
            $start = substr($m[1], 0, 1);
            $end = substr($m[1], -1);

            if ($start === $end) {
                return !preg_match('/[*?[:alnum:] \\\\]/', $start);
            }

            foreach ([['{', '}'], ['(', ')'], ['[', ']'], ['<', '>']] as $delimiters) {
                if ($start === $delimiters[0] && $end === $delimiters[1]) {
                    return true;
                }
            }
        }

        return false;
    }
387114
public static function endsWith(string $base, string $ends) : bool
    {
        if($ends === "") {
            return true;
        }

        $temp = strlen($base) - strlen($ends);

        if(
            $temp >= 0 &&
            strpos($base, $ends, $temp) !== false
        ) {
            return true;
        }

        return false;
    }
667037
protected function strEndsWith($str, $end)
    {
        return substr_compare($str, $end, -strlen($end), strlen($end)) === 0;
    }
597344
public static boolean endsWithPunc(String str) {
		if (str.endsWith(".") || str.endsWith("?") || str.endsWith("!") ||
			    str.endsWith(",") || str.endsWith(":") || str.endsWith("\"") || 
			    str.endsWith("'") || str.endsWith("''") || str.endsWith(";")) {
		    return true;
		}
		
		return false;
    }
1097592
protected function findEndingBasedMatch($string)
    {
        list($firstPart, $separator, $lastPart) = $this->splitLastWord($string);

        foreach ($this->endings as $ending => $forms) {

            // keep track of some special cases, so we
            // may better handle replacements
            $specialCase = null;

            if (strstr($ending, 'DSC')) {
                $specialCase  = static::DOUBLE_SAME_CONSONANT;
            } elseif (strstr($ending, 'DSV')) {
                $specialCase  = static::DOUBLE_SAME_VOWEL;
            }

            $ending = str_replace(
                [
                    'DSC',
                    'DSV',
                    'C',
                    'V!I',
                    'V',
                ],
                [
                    static::DOUBLE_SAME_CONSONANT,
                    static::DOUBLE_SAME_VOWEL,
                    static::CONSONANT,
                    static::VOWEL_EXCEPT_I,
                    static::VOWEL,
                ],
                $ending
            );

            if ($this->debug) {
                var_dump('#^(.*)' . $ending . '$#i');
            }

            if (preg_match('#^(.*)' . $ending . '$#i', $lastPart, $matches)) {

                $newSingularEnd  = preg_replace('#' . $ending . '$#i', $forms[0], $lastPart);
                $newPluralizeEnd = preg_replace('#' . $ending . '$#i', $forms[1], $lastPart);

                if ($this->camelCased && strlen($firstPart)) {
                    $newSingularEnd  = ucfirst($newSingularEnd);
                    $newPluralizeEnd = ucfirst($newPluralizeEnd);
                }

                $fixedForms = [
                    'singular' => $firstPart . $separator . $newSingularEnd,
                    'plural'   => $firstPart . $separator . $newPluralizeEnd,
                ];

                // handle exceptions
                if (    $specialCase == static::DOUBLE_SAME_CONSONANT
                    ||  $specialCase == static::DOUBLE_SAME_VOWEL
                ) {
                    $single = '';

                    // find the double same vowel match, get a single character from it
                    for ($x = count($matches) - 1; $x > 0; $x--) {
                        if (preg_match('#' . $specialCase . '#i', $matches[$x])) {
                            $single = substr($matches[$x], 0, 1);
                            break;
                        }
                    }

                    $fixedForms['singular'] = str_replace(':SINGLE:', $single, $fixedForms['singular']);
                    $fixedForms['plural']   = str_replace(':SINGLE:', $single, $fixedForms['plural']);
                }

                return $fixedForms;
            }
        }

        return false;
    }
436513
public void endsWith(String string) {
    checkNotNull(string);
    if (actual() == null) {
      failWithActual("expected a string that ends with", string);
    } else if (!actual().endsWith(string)) {
      failWithActual("expected to end with", string);
    }
  }
354830
public static function byteStrBetween($string, $start, $end = null)
    {
        if (($startPos = static::byteStrPos($string, $start)) !== false) {
            if ($end) {
                if (($end_pos = static::byteStrPos($string, $end, $startPos + static::byteLength($start))) !== false) {
                    return static::byteSubstr($string, $startPos + static::byteLength($start), $end_pos - ($startPos + static::byteLength($start)));
                }
            } else {
                return static::byteSubstr($string, $startPos);
            }
        }
        return false;
    }
720553
public static function startsWith($string, $beginning)
    {
        if (!empty($string) && !empty($beginning)) {
            if (1 === strlen($beginning) && !self::isLetterOrDigit($beginning)) {
                $beginning = '\\' . $beginning;
            }

            $pattern = sprintf('|^%s|', $beginning);

            return (bool)preg_match($pattern, $string);
        }

        return false;
    }
541393
private function findAllTextBetween($beginning, $end, $string) {
    $beginningPos = strpos($string, $beginning);
    $endPos = strpos($string, $end);
    if ($beginningPos === false || $endPos === false) {
      return '';
    }

    $textToDelete = substr($string, $beginningPos, ($endPos + strlen($end)) - $beginningPos);

    return $textToDelete;
  }
1061074
public function limitWords($string, $limit = false, $end = '...')
    {
        $words = explode(" ", $string);

        if (count($words) <= $limit) {
            return $string;
        }

        $return = [];
        for ($wordCount = 0; $wordCount < $limit; $wordCount++) {
            $return[] = $words[$wordCount];
        }

        $return[] = $end;

        return implode(" ", $return);
    }