lime /lib/mock/LimeMockTemplate.php

Language PHP Lines 57
MD5 Hash 46cb96cd5fd1b331cb086b1500464827 Estimated Cost $352 (why?)
Repository git://github.com/bschussek/lime.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php

/*
 * This file is part of the Lime test framework.
 *
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 * (c) Bernhard Schussek <bernhard.schussek@symfony-project.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

/**
 * Reads template files and parses them with a set of template variables.
 *
 * @package    Lime
 * @author     Bernhard Schussek <bernhard.schussek@symfony-project.com>
 * @version    SVN: $Id: LimeMockTemplate.php 23701 2009-11-08 21:23:40Z bschussek $
 */
class LimeMockTemplate
{
  private
    $parameters   = array(),
    $filename     = '';

  /**
   * Constructor.
   *
   * Configures this template to use the given file.
   *
   * @param string $filename
   */
  public function __construct($filename)
  {
    $this->filename = $filename;
  }

  /**
   * Renders the file of this template with the given parameters.
   *
   * The parameters are made available in the template and can be accessed there
   * as normal PHP variables. The template is parsed and the output of the
   * template is returned.
   *
   * @param  array $parameters
   * @return string
   */
  public function render(array $parameters)
  {
    ob_start();
    extract($parameters);
    include $this->filename;

    return ob_get_clean();
  }

}
Back to Top