Completed
Push — master ( c686d8...1d0354 )
by Mehmet
05:00
created
src/Twig/TwigExtensions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
     /**
64 64
      * Build translate array.
65 65
      * @param $translateArray
66
-     * @return array
66
+     * @return string
67 67
      */
68 68
     private function buildTranslateArray(array $translateArray) {
69 69
         $tmpArray = [];
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     private function buildTranslateArray(array $translateArray) {
69 69
         $tmpArray = [];
70 70
         foreach ($translateArray as $key => $value) {
71
-            $tmpArray['@'.$key] = $value;
71
+            $tmpArray['@' . $key] = $value;
72 72
         }
73 73
         return $tmpArray;
74 74
     }
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
                     $relative_path = $data;
87 87
                     foreach ($params as $param => $value) {
88 88
                         if (strpos($param, ':') === strlen($param)-1) {
89
-                            $relative_path = preg_replace('/{'.$param.'(.*?)}/msi', $value, $relative_path);
89
+                            $relative_path = preg_replace('/{' . $param . '(.*?)}/msi', $value, $relative_path);
90 90
                         } else {
91
-                            $relative_path = str_replace('{'.$param.'}', $value, $relative_path);
91
+                            $relative_path = str_replace('{' . $param . '}', $value, $relative_path);
92 92
                         }
93 93
                     }
94 94
                     return $this->config['base_url'] . '/' . $relative_path;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                     throw new InvalidArgumentException($templateFileBasename . ' template file not found! ' . $widgetNameStr
127 127
                         . '_' . $widgetActionStr . ' needs a main template file at:' . $templateFullPath);
128 128
                 }
129
-                $templateFile =  '_widgets/'
129
+                $templateFile = '_widgets/'
130 130
                     . $this->toSnakeCase->transform($widgetNameStr) . '/' . $templateFileBasename;
131 131
                 $widgetData = $widgetInstance->{$widgetAction}();
132 132
                 return $this->twig->render($templateFile, $widgetData);
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
                 string $linkItemTemplate = '<a href="(href)" class="(link_class)">(text)</a>',
188 188
                 string $ellipsesTemplate = '<li><a>...</a></li>'
189 189
             ) {
190
-                $items =  '';
190
+                $items = '';
191 191
                 $pageGroupLimit = 3;
192
-                $useEllipses = ($total >10) ? 1 : 0;
192
+                $useEllipses = ($total > 10) ? 1 : 0;
193 193
                 $renderedEllipses = 0;
194 194
                 $values = [
195 195
                     '(item_class)'  => '',
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                     '(link_class)'  => '',
198 198
                     '(text)'  => ''
199 199
                 ];
200
-                for ($i=1; $i <= $total; $i++) {
200
+                for ($i = 1; $i <= $total; $i++) {
201 201
                     $values['(link_class)'] = '';
202 202
                     $values['(item_class)'] = '';
203 203
                     if ($i === $current) {
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
                     $useLink = 1;
211 211
                     if ($useEllipses === 1) {
212 212
                         $useLink = 0;
213
-                        if ( ($i <= $pageGroupLimit) ||  ($i >= ($current-1) && $i <= ($current+1)) || ($i >= ($total-2)) ) {
213
+                        if (($i <= $pageGroupLimit) || ($i >= ($current-1) && $i <= ($current+1)) || ($i >= ($total-2))) {
214 214
                             $useLink = 1;
215 215
                             $renderedEllipses = 0;
216 216
                         } else {
217 217
 
218
-                            if($renderedEllipses === 0) {
218
+                            if ($renderedEllipses === 0) {
219 219
                                 $items .= $ellipsesTemplate;
220 220
                             }
221 221
                             $renderedEllipses = 1;
222 222
                         }
223 223
                     }
224
-                    if($useLink === 1 ) {
224
+                    if ($useLink === 1) {
225 225
                         $thisItemTemplate = str_replace(
226 226
                             array('(link)'),
227 227
                             array($link),
Please login to merge, or discard this patch.
src/Twig/Twig.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     ];
18 18
     public function __construct($config, $queryParams)
19 19
     {
20
-        $this->config = array_merge($this->config,$config);
20
+        $this->config = array_merge($this->config, $config);
21 21
         $loader     = new \Twig_Loader_Filesystem($this->config['templates_dir']);
22 22
         $this->twig = new \Twig_Environment($loader, [
23 23
             'cache'         => $this->config['cache_dir'],
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $this->twig->addGlobal($name, $value);
35 35
     }
36 36
 
37
-    public function render(string $templateFile, array $parameters=[])
37
+    public function render(string $templateFile, array $parameters = [])
38 38
     {
39 39
         $output = $this->twig->render($templateFile, $parameters);
40 40
         preg_match('/{{(\s*)Widget\_/msi', $output, $matches);
Please login to merge, or discard this patch.
src/ExtensionsAbstract.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * Load functions that will be used in the templates
15 15
      */
16
-    protected function loadFunctions(){
16
+    protected function loadFunctions() {
17 17
         $this->extendForTranslation();
18 18
         $this->extendForWidget();
19 19
         $this->extendForPagination();
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
     /**
28 28
      * Load extensions of templating engines
29 29
      */
30
-    protected function loadExtensions(){}
30
+    protected function loadExtensions() {}
31 31
 
32 32
     /**
33 33
      * Extend for function _t that translates using defined global lang variable
34 34
      * $lang = ['name' => 'Selami']
35 35
      * {{ _t('Hello @name',lang) }} produces Hello Selami
36 36
      */
37
-    protected function extendForTranslation(){}
37
+    protected function extendForTranslation() {}
38 38
 
39 39
     /**
40 40
      * Extend for function getUrl that returns url path for an alias.
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * and $baseUrl = 'http://127.0.0.1' and $page_lang = 'en_US'
49 49
      * {{ getUrl('about', {'lang': page_lang}) }} produces http://127.0.0.1/en_US/about-us
50 50
      */
51
-    protected function extendForGetUrl(){}
51
+    protected function extendForGetUrl() {}
52 52
 
53 53
     /**
54 54
      * Extend for wildcard Widget functions. Widget function determines the class and method that will be called.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      *  }
60 60
      *  )();
61 61
      */
62
-    protected function extendForWidget(){}
62
+    protected function extendForWidget() {}
63 63
 
64 64
     /**
65 65
      * Extend for queryParams function that returns http_build_query result using passed parameters.
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
      * {{ queryParams({'param1':1,'param2':2}, $prefix) }} returns ?param1=1&param2=2
68 68
      *
69 69
      */
70
-    protected function extendForQueryParams(){}
70
+    protected function extendForQueryParams() {}
71 71
 
72 72
     /**
73 73
      * Extend for function siteUrl that returns defined baseUrl of the site
74 74
      * Let's say $baseUrl = 'http://127.0.0.1';
75 75
      * {{ siteUrl('/home') }} produces http://127.0.0.1/home
76 76
      */
77
-    protected function extendForSiteUrl(){}
77
+    protected function extendForSiteUrl() {}
78 78
 
79 79
     /**
80 80
      * Extend for function varDump. Just outputs var_dump of passed parameter.
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      * Use it for debugging purposes.
83 83
      *
84 84
      */
85
-    protected function extendForVarDump(){}
85
+    protected function extendForVarDump() {}
86 86
 
87 87
     /**
88 88
      * Extend for function Pagination. This function builds pagination html.
@@ -117,5 +117,5 @@  discard block
 block discarded – undo
117 117
      *      <li><a href="/list?page_num=20" class="">3</a></li>
118 118
      * </ul>
119 119
      */
120
-    protected function extendForPagination(){}
120
+    protected function extendForPagination() {}
121 121
 }
122 122
\ No newline at end of file
Please login to merge, or discard this patch.
src/ViewInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,5 +7,5 @@
 block discarded – undo
7 7
 {
8 8
     public function addGlobal(string $name, $value);
9 9
 
10
-    public function render(string $templateFile, array $parameters=[]);
10
+    public function render(string $templateFile, array $parameters = []);
11 11
 }
12 12
\ No newline at end of file
Please login to merge, or discard this patch.