Yosymfony\Spress\Core\Support\StringWrapper::deleteSufix PHP Method

deleteSufix() public method

Deletes a sufix of the string.
public deleteSufix ( string $sufix ) : string
$sufix string The sufix
return string The string without sufix
    public function deleteSufix($sufix)
    {
        if ($this->endWith($sufix) === true) {
            return substr($this->str, 0, -strlen($sufix));
        }
        return $this->str;
    }

Usage Example

示例#1
0
 public function testDeleteSufix()
 {
     $str = new StringWrapper('Welcome to Spress');
     $this->assertEquals('Welcome to', $str->deleteSufix(' Spress'));
     $this->assertEquals('Welcome to Spress', $str->deleteSufix('Hi'));
     $this->assertEquals('Welcome to Spress', $str->deleteSufix(''));
 }
All Usage Examples Of Yosymfony\Spress\Core\Support\StringWrapper::deleteSufix