JoliTypo\Fixer\SmartQuotes::fix PHP Method

fix() public method

public fix ( $content, StateBag $stateBag = null )
$stateBag JoliTypo\StateBag
    public function fix($content, StateBag $stateBag = null)
    {
        if (!$this->opening || !$this->closing) {
            throw new BadFixerConfigurationException();
        }
        // Fix complex siblings cases
        if ($stateBag) {
            $content = $this->fixViaState($content, $stateBag, 'SmartQuotesOpenSolo', '@(^|\\s|\\()"([^"]*)$@im', '@(^|[^"]+)"@im', $this->opening . $this->openingSuffix, $this->closingPrefix . $this->closing);
        }
        // Fix simple cases
        $content = preg_replace('@(^|\\s|\\()"([^"]+)"@im', '$1' . $this->opening . $this->openingSuffix . '$2' . $this->closingPrefix . $this->closing, $content);
        return $content;
    }

Usage Example

Beispiel #1
0
 /**
  * @expectedException \JoliTypo\Exception\BadFixerConfigurationException
  */
 public function testBadConfig()
 {
     $fixer = new Fixer\SmartQuotes('unknown');
     $fixer->fix("nope");
 }