TYPO3 API  SVNRelease
StringReplacementFilterFactory.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * This file is part of SwiftMailer.
00005  * (c) 2004-2009 Chris Corbyn
00006  *
00007  * For the full copyright and license information, please view the LICENSE
00008  * file that was distributed with this source code.
00009  */
00010 
00011 //@require 'Swift/StreamFilters/StringReplacementFilter.php';
00012 //@require 'Swift/StreamFilterFactory.php';
00013 
00014 /**
00015  * Creates filters for replacing needles in a string buffer.
00016  * @package Swift
00017  * @author Chris Corbyn
00018  */
00019 class Swift_StreamFilters_StringReplacementFilterFactory
00020   implements Swift_ReplacementFilterFactory
00021 {
00022 
00023   /** Lazy-loaded filters */
00024   private $_filters = array();
00025 
00026   /**
00027    * Create a new StreamFilter to replace $search with $replace in a string.
00028    * @param string $search
00029    * @param string $replace
00030    * @return Swift_StreamFilter
00031    */
00032   public function createFilter($search, $replace)
00033   {
00034     if (!isset($this->_filters[$search][$replace]))
00035     {
00036       if (!isset($this->_filters[$search]))
00037       {
00038         $this->_filters[$search] = array();
00039       }
00040 
00041       if (!isset($this->_filters[$search][$replace]))
00042       {
00043         $this->_filters[$search][$replace] = array();
00044       }
00045 
00046       $this->_filters[$search][$replace]
00047         = new Swift_StreamFilters_StringReplacementFilter($search, $replace);
00048     }
00049 
00050     return $this->_filters[$search][$replace];
00051   }
00052 
00053 }