Completed
Push — master ( bf06ad...9a7adb )
by Martin
01:18
created
src/Twig/DataToTwigConvertor.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function nothing(): self
31 31
     {
32
-        return new static(function (array $data) {
32
+        return new static(function(array $data) {
33 33
             return '';
34 34
         });
35 35
     }
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public static function vars(bool $force = true): self
42 42
     {
43
-        return new static(function (array $data) use ($force) {
43
+        return new static(function(array $data) use ($force) {
44 44
             $content = '';
45 45
             foreach ($data as $key => $value) {
46 46
                 if (preg_match('/^[a-z][0-9a-z_]*$/i', $key)) {
47
-                    $content .= "{% set $key = " . ($force ? '' : "$key is defined ? $key : ") . static::valueToTwig($value) . " %}\n";
47
+                    $content .= "{% set $key = ".($force ? '' : "$key is defined ? $key : ").static::valueToTwig($value)." %}\n";
48 48
                 }
49 49
             }
50 50
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public static function var(string $name, bool $force = true): self
63 63
     {
64
-        return new static(function (array $data) use ($name, $force) {
65
-            return "{% set $name = " . ($force ? '' : "$name is defined ? $name : ") . static::valueToTwig($data) . "%}\n";
64
+        return new static(function(array $data) use ($name, $force) {
65
+            return "{% set $name = ".($force ? '' : "$name is defined ? $name : ").static::valueToTwig($data)."%}\n";
66 66
         });
67 67
     }
68 68
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     public static function valueToTwig($value): string
77 77
     {
78 78
         if ($value instanceof \DateTimeInterface) {
79
-            return '(' . $value->getTimestamp() . "|date_modify('0sec'))";
79
+            return '('.$value->getTimestamp()."|date_modify('0sec'))";
80 80
         } elseif (is_array($value)) {
81 81
             $twig = '{';
82 82
             foreach ($value as $key => $val) {
Please login to merge, or discard this patch.