Stringy\Stringy::endsWith PHP Метод

endsWith() публичный метод

Returns true if the string ends with $substring, false otherwise. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
public endsWith ( string $substring, boolean $caseSensitive = true ) : boolean
$substring string The substring to look for
$caseSensitive boolean Whether or not to enforce case-sensitivity
Результат boolean Whether or not $str ends with $substring
    public function endsWith($substring, $caseSensitive = true)
        $substringLength = \mb_strlen($substring, $this->encoding);
        $strLength = $this->length();
        $endOfStr = \mb_substr($this->str, $strLength - $substringLength, $substringLength, $this->encoding);
        if (!$caseSensitive) {
            $substring = \mb_strtolower($substring, $this->encoding);
            $endOfStr = \mb_strtolower($endOfStr, $this->encoding);
        return (string) $substring === $endOfStr;

Usage Example

Пример #1
 private function isAlbum()
     if (!empty($this->parsedUrl['path'])) {
         // TODO: как правильно вызывать Stringy чтобы не создавать 100 экземпляров внутри кода?
         $stringy = new Stringy();
         $result = $stringy->endsWith(Urls::ALBUM);
         if ($result === true) {
             return true;
     return false;