Completed
Push — master ( cb5507...0a6922 )
by Son
05:10
created
src/Templater.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,6 +78,7 @@  discard block
 block discarded – undo
78 78
      * Load adapter, currently we are using 2 adapters: twig and blade
79 79
      * 
80 80
      * @var     $adapter_name       string            Path to template folder.
81
+     * @param string $adapter_name
81 82
      * @return  mixed
82 83
      */
83 84
     public function loadAdapter($adapter_name) {
@@ -119,7 +120,7 @@  discard block
 block discarded – undo
119 120
      * 
120 121
      * @var     $app_name       string              Your application name, should be lowercase, letters only.
121 122
      * 
122
-     * @return                  object              \VA\Templater\Engine
123
+     * @return                  Templater              \VA\Templater\Engine
123 124
      */
124 125
     public function setWordPressThemeSupport($app_name) {
125 126
         // Path to templates folder in wordpress theme
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      * 
22 22
      * @var     $adapter    object               Template Engine object
23 23
      */
24
-    private $adapter = [];
24
+    private $adapter = [ ];
25 25
     
26 26
     /**
27 27
      * Template adapter, it would be twig or any php template lib.
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      * @return  Twig_Environment
56 56
      */
57 57
     public function loadTwig() {
58
-        if(!$this->adapter) {
58
+        if (!$this->adapter) {
59 59
             $loader             = new Twig_Loader_Filesystem($this->dir_path);
60 60
             $this->adapter      = new Twig_Environment($loader, array(
61 61
             
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @return Blade
71 71
      */
72 72
     public function loadBlade() {
73
-        $this->adapter = new Blade($this->dir_path,'/tmp');//second parameter is where cache view is located.
73
+        $this->adapter = new Blade($this->dir_path, '/tmp'); //second parameter is where cache view is located.
74 74
         return $this->adapter;
75 75
     }
76 76
     
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
      * @return  mixed
82 82
      */
83 83
     public function loadAdapter($adapter_name) {
84
-        if(!$this->adapter) { //
84
+        if (!$this->adapter) { //
85 85
             $method_name = 'load'.ucfirst($adapter_name);
86
-            if(method_exists($this, $method_name)) {
86
+            if (method_exists($this, $method_name)) {
87 87
                 $this->$method_name();
88
-            }else{
88
+            }else {
89 89
                 throw new \Exception("Could not load adapter $adapter_name");
90 90
             }
91 91
         }
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
      * 
101 101
      * @return                  string              Rendered HTML/text
102 102
      */
103
-    public function render($template, $data = []) {
104
-        if($this->adapter_name == 'twig')
103
+    public function render($template, $data = [ ]) {
104
+        if ($this->adapter_name == 'twig')
105 105
         {
106 106
             return $this->adapter->render($template, $data);
107 107
         }
108
-        elseif($this->adapter_name == 'blade')
108
+        elseif ($this->adapter_name == 'blade')
109 109
         {
110
-            return $this->adapter->view()->make($template,$data)->render();
110
+            return $this->adapter->view()->make($template, $data)->render();
111 111
         }
112 112
     }
113 113
     
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function setWordPressThemeSupport($app_name) {
125 125
         // Path to templates folder in wordpress theme
126
-        $theme_template_path = get_template_directory() . '/templates/'. $app_name;
126
+        $theme_template_path = get_template_directory().'/templates/'.$app_name;
127 127
         
128 128
         // Create folder path if it does not exists.
129
-        if(!file_exists($theme_template_path)) {
129
+        if (!file_exists($theme_template_path)) {
130 130
             wp_mkdir_p($theme_template_path);
131 131
         }
132 132
         
133 133
         // Preapare template folders
134 134
         $template_folders = [
135
-			$theme_template_path,   // Load this path first
135
+			$theme_template_path, // Load this path first
136 136
 			$this->dir_path         // Load this path second
137 137
 		];
138 138
 		$loader = new \Twig_Loader_Filesystem($template_folders);
Please login to merge, or discard this patch.
Braces   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             $method_name = 'load'.ucfirst($adapter_name);
86 86
             if(method_exists($this, $method_name)) {
87 87
                 $this->$method_name();
88
-            }else{
88
+            } else{
89 89
                 throw new \Exception("Could not load adapter $adapter_name");
90 90
             }
91 91
         }
@@ -104,8 +104,7 @@  discard block
 block discarded – undo
104 104
         if($this->adapter_name == 'twig')
105 105
         {
106 106
             return $this->adapter->render($template, $data);
107
-        }
108
-        elseif($this->adapter_name == 'blade')
107
+        } elseif($this->adapter_name == 'blade')
109 108
         {
110 109
             return $this->adapter->view()->make($template,$data)->render();
111 110
         }
Please login to merge, or discard this patch.