浏览代码

[FrameworkBundle] prettified Mustache.php and added PHPDoc.

henrikbjorn 14 年之前
父节点
当前提交
6b61af5931
共有 1 个文件被更改,包括 25 次插入6 次删除
  1. 25 6
      src/Symfony/Bundle/FrameworkBundle/Util/Mustache.php

+ 25 - 6
src/Symfony/Bundle/FrameworkBundle/Util/Mustache.php

@@ -14,26 +14,45 @@ namespace Symfony\Bundle\FrameworkBundle\Util;
 /**
  * Mustache.
  *
- * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
+ * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  */
 class Mustache
 {
-    static public function renderString($string, $parameters)
+    /**
+     * Renders a single line. Looks for {{ var }}
+     *
+     * @param string $string
+     * @param array $parameters
+     *
+     * @return string
+     */
+    static public function renderString($string, array $parameters)
     {
-        $replacer = function ($match) use($parameters)
-        {
+        $replacer = function ($match) use ($parameters) {
             return isset($parameters[$match[1]]) ? $parameters[$match[1]] : $match[0];
         };
 
         return preg_replace_callback('/{{\s*(.+?)\s*}}/', $replacer, $string);
     }
 
-    static public function renderFile($file, $parameters)
+    /**
+     * Renders a file by replacing the contents of $file with rendered output.
+     *
+     * @param string $file filename for the file to be rendered
+     * @param array $parameters
+     */
+    static public function renderFile($file, array $parameters)
     {
         file_put_contents($file, static::renderString(file_get_contents($file), $parameters));
     }
 
-    static public function renderDir($dir, $parameters)
+    /**
+     * Renders a directory recursively
+     *
+     * @param string $dir Path to the directory that will be recursively rendered
+     * @param array $parameters
+     */
+    static public function renderDir($dir, array $parameters)
     {
         foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
             if ($file->isFile()) {