1 <?php namespace CupOfTea\EasyCfg;
2
3 class Compiler
4 {
5
6 /**
7 * Compile @cfg directives.
8 *
9 * @param string $value
10 * @return string
11 */
12 public function compile($value)
13 {
14 $value = preg_replace('/@cfg\((\'|")((?:(?!\1).)*)\1\)/i', '@yield($1_cfg_$2$1)', $value);
15 $value = preg_replace('/@cfg\((\'|")((?:(?!\1).)*)\1,\s*(\'|")((?:(?!\3).)*)\3\)/i', "@section($1_cfg_$2$1)$4 @endsection", $value);
16
17 return $value;
18 }
19 }
20