Completed
Push — master ( 86484b...f97b0a )
by stéphane
05:27
created
examples/load_modify_save.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Dallgoot\Yaml;
3 3
 
4
-require_once __DIR__ . '/../../dependencies/autoload.php';
4
+require_once __DIR__.'/../../dependencies/autoload.php';
5 5
 
6 6
 use Dallgoot;
7 7
 
8
-$fileName = __DIR__ . '/../dummy.yml';
8
+$fileName = __DIR__.'/../dummy.yml';
9 9
 
10 10
 $yamlObject = Yaml::parseFile($fileName, $options = null, $debug = null);
11 11
 
Please login to merge, or discard this patch.
sources/nodes/NodeComment.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@
 block discarded – undo
10 10
  */
11 11
 class NodeComment extends Node
12 12
 {
13
-   public function specialProcess(Node &$previous, array &$emptyLines):bool
14
-   {
13
+    public function specialProcess(Node &$previous, array &$emptyLines):bool
14
+    {
15 15
         $previous->getRoot()->add($this);
16 16
         return true;
17
-   }
17
+    }
18 18
 
19
-   public function build(&$parent = null)
20
-   {
19
+    public function build(&$parent = null)
20
+    {
21 21
         $root = $this->getRoot();
22 22
         $yamlObject = $root->getYamlObject();
23 23
         $yamlObject->addComment($this->line, $this->raw);
24
-   }
24
+    }
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
sources/nodes/NodeCompactSequence.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     public function __construct(string $nodeString, int $line)
14 14
     {
15 15
         parent::__construct($nodeString, $line);
16
-        preg_match_all(Regex::SEQUENCE_VALUES, trim(substr(trim($nodeString), 1,-1)), $matches);
16
+        preg_match_all(Regex::SEQUENCE_VALUES, trim(substr(trim($nodeString), 1, -1)), $matches);
17 17
         foreach ($matches['item'] as $key => $item) {
18 18
             $i = new NodeItem('', $line);
19 19
             $i->indent = null;
Please login to merge, or discard this patch.
sources/nodes/NodeQuoted.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
 {
13 13
     public function build(&$parent = null)
14 14
     {
15
-        return substr(trim($this->raw), 1,-1);
15
+        return substr(trim($this->raw), 1, -1);
16 16
     }
17 17
 }
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
sources/nodes/NodeSetKey.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     public function build(&$parent = null)
30 30
     {
31 31
         $built = is_null($this->value) ? null : $this->value->build();
32
-        $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" '): $built;
32
+        $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" ') : $built;
33 33
         $key = json_encode($stringKey, JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES);
34 34
         if (empty($key)) throw new \Exception("Cant serialize complex key: ".var_export($this->value, true));
35 35
         $parent->{trim($key, '\'" ')} = null;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@
 block discarded – undo
31 31
         $built = is_null($this->value) ? null : $this->value->build();
32 32
         $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" '): $built;
33 33
         $key = json_encode($stringKey, JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES);
34
-        if (empty($key)) throw new \Exception("Cant serialize complex key: ".var_export($this->value, true));
34
+        if (empty($key)) {
35
+            throw new \Exception("Cant serialize complex key: ".var_export($this->value, true));
36
+        }
35 37
         $parent->{trim($key, '\'" ')} = null;
36 38
     }
37 39
 
Please login to merge, or discard this patch.
sources/nodes/NodeScalar.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
 
44 44
     public function getTargetOnLessIndent(Node &$node):Node
45 45
     {
46
-        if ($node instanceof NodeScalar || $node instanceof NodeBlank ) {
46
+        if ($node instanceof NodeScalar || $node instanceof NodeBlank) {
47 47
             return $this->getParent();
48 48
         } else {
49 49
             return $this->getParent($node->indent);
Please login to merge, or discard this patch.
sources/Node.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         return false;
131 131
     }
132 132
 
133
-   /**
133
+    /**
134 134
      * Find parent target when current Node indentation is lesser than previous node indentation
135 135
      *
136 136
      * @param Node $previous The previous
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         return $this->getParent();
167 167
     }
168 168
 
169
-   /**
169
+    /**
170 170
      * Find parent target when current Node indentation is superior than previous node indentation
171 171
      *
172 172
      * @param Node $previous The previous
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function getParent(int $indent = null):Node
67 67
     {
68
-        if (!is_int($indent)){
68
+        if (!is_int($indent)) {
69 69
             if ($this->_parent instanceof Node) {
70 70
                 return $this->_parent;
71 71
             } else {
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         if ($this->tag)        $props['tag']        = "($this->tag)";
216 216
         if ($this->value)      $props['value']      = $this->value;
217 217
         // $props['value'] = $this->value;
218
-        $props['raw']   = $this->raw;
218
+        $props['raw'] = $this->raw;
219 219
         if (!$this->_parent)  $props['parent'] = 'NO PARENT!!!';
220 220
         return $props;
221 221
     }
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -210,13 +210,23 @@
 block discarded – undo
210 210
     {
211 211
         $props = [];
212 212
         $props['line->indent'] = "$this->line -> $this->indent";
213
-        if ($this->identifier) $props['identifier'] = "($this->identifier)";
214
-        if ($this->anchor)     $props['anchor']     = "($this->anchor)";
215
-        if ($this->tag)        $props['tag']        = "($this->tag)";
216
-        if ($this->value)      $props['value']      = $this->value;
213
+        if ($this->identifier) {
214
+            $props['identifier'] = "($this->identifier)";
215
+        }
216
+        if ($this->anchor) {
217
+            $props['anchor']     = "($this->anchor)";
218
+        }
219
+        if ($this->tag) {
220
+            $props['tag']        = "($this->tag)";
221
+        }
222
+        if ($this->value) {
223
+            $props['value']      = $this->value;
224
+        }
217 225
         // $props['value'] = $this->value;
218 226
         $props['raw']   = $this->raw;
219
-        if (!$this->_parent)  $props['parent'] = 'NO PARENT!!!';
227
+        if (!$this->_parent) {
228
+            $props['parent'] = 'NO PARENT!!!';
229
+        }
220 230
         return $props;
221 231
     }
222 232
 }
Please login to merge, or discard this patch.
sources/API.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
             return $this->_anchors[$name];
70 70
         }
71 71
         throw new \UnexpectedValueException(sprintf(self::UNKNOWN_REFERENCE,
72
-                                                    $name, implode(',',array_keys($this->_anchors)))
72
+                                                    $name, implode(',', array_keys($this->_anchors)))
73 73
                                                 );
74 74
     }
75 75
 
Please login to merge, or discard this patch.
sources/types/YamlObject.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@
 block discarded – undo
46 46
     public function __call($funcName, $arguments)
47 47
     {
48 48
         $reflectAPI = new \ReflectionClass(get_class($this->__yaml__object__api));
49
-        $getName    = function ($o) { return $o->name; };
49
+        $getName    = function($o) { return $o->name; };
50 50
         $publicApi  = array_map($getName, $reflectAPI->getMethods(\ReflectionMethod::IS_PUBLIC));
51
-        if (!in_array($funcName, $publicApi) ) {
51
+        if (!in_array($funcName, $publicApi)) {
52 52
             throw new \BadMethodCallException(sprintf(self::UNDEFINED_METHOD, $funcName, implode(",", $publicApi)));
53 53
         }
54 54
         return call_user_func_array([$this->__yaml__object__api, $funcName], $arguments);
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,8 +74,12 @@
 block discarded – undo
74 74
     {
75 75
         $prop = get_object_vars($this);
76 76
         unset($prop["__yaml__object__api"]);
77
-        if (count($prop) > 0) return $prop;
78
-        if (count($this) > 0) return iterator_to_array($this);
77
+        if (count($prop) > 0) {
78
+            return $prop;
79
+        }
80
+        if (count($this) > 0) {
81
+            return iterator_to_array($this);
82
+        }
79 83
         return $this->__yaml__object__api->value ?? "_Empty YamlObject_";
80 84
     }
81 85
 }
Please login to merge, or discard this patch.