deleteSufix() public method

Deletes a sufix of the string.
public deleteSufix ( string $sufix ) : string
$sufix string The sufix
return string The string without sufix
示例#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(''));
 }
示例#2
0
 private function convertItem(ItemInterface $item)
 {
     $path = $item->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE);
     if ($item->isBinary() === true) {
         $item->setPath($path, ItemInterface::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT);
         return;
     }
     $this->eventDispatcher->dispatch('spress.before_convert', new Event\ContentEvent($item, ItemInterface::SNAPSHOT_RAW, ItemInterface::SNAPSHOT_PATH_RELATIVE));
     $result = $this->converterManager->convertItem($item);
     $str = new StringWrapper($path);
     $filenameWithoutExtension = $str->deleteSufix($result->getInputExtension());
     $newPath = $filenameWithoutExtension . $result->getExtension();
     $item->setContent($result->getResult(), ItemInterface::SNAPSHOT_AFTER_CONVERT);
     $item->setPath($newPath, ItemInterface::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT);
     $this->eventDispatcher->dispatch('spress.after_convert', new Event\ContentEvent($item, ItemInterface::SNAPSHOT_AFTER_CONVERT, ItemInterface::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT));
 }