PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/vendor/swift/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php

http://zoop.googlecode.com/
PHP | 53 lines | 23 code | 9 blank | 21 comment | 3 complexity | 6064e9e7e02fdec0b50cc2d3f03cc8b2 MD5 | raw file
 1<?php
 2
 3/*
 4 * This file is part of SwiftMailer.
 5 * (c) 2004-2009 Chris Corbyn
 6 *
 7 * For the full copyright and license information, please view the LICENSE
 8 * file that was distributed with this source code.
 9 */
10
11//@require 'Swift/StreamFilters/StringReplacementFilter.php';
12//@require 'Swift/StreamFilterFactory.php';
13
14/**
15 * Creates filters for replacing needles in a string buffer.
16 * @package Swift
17 * @author Chris Corbyn
18 */
19class Swift_StreamFilters_StringReplacementFilterFactory
20  implements Swift_ReplacementFilterFactory
21{
22  
23  /** Lazy-loaded filters */
24  private $_filters = array();
25  
26  /**
27   * Create a new StreamFilter to replace $search with $replace in a string.
28   * @param string $search
29   * @param string $replace
30   * @return Swift_StreamFilter
31   */
32  public function createFilter($search, $replace)
33  {
34    if (!isset($this->_filters[$search][$replace]))
35    {
36      if (!isset($this->_filters[$search]))
37      {
38        $this->_filters[$search] = array();
39      }
40      
41      if (!isset($this->_filters[$search][$replace]))
42      {
43        $this->_filters[$search][$replace] = array();
44      }
45      
46      $this->_filters[$search][$replace]
47        = new Swift_StreamFilters_StringReplacementFilter($search, $replace);
48    }
49    
50    return $this->_filters[$search][$replace];
51  }
52  
53}