@@ -105,7 +105,9 @@ discard block |
||
| 105 | 105 | return Attribute::make( |
| 106 | 106 | get: function () { |
| 107 | 107 | // Check for error indicators in input data |
| 108 | - if (!$this->input) return true; |
|
| 108 | + if (!$this->input) { |
|
| 109 | + return true; |
|
| 110 | + } |
|
| 109 | 111 | |
| 110 | 112 | $input = is_array($this->input) ? $this->input : $this->input->toArray(); |
| 111 | 113 | return !isset($input['error']) && !isset($input['exception']); |
@@ -122,7 +124,9 @@ discard block |
||
| 122 | 124 | { |
| 123 | 125 | return Attribute::make( |
| 124 | 126 | get: function () { |
| 125 | - if (!$this->input) return []; |
|
| 127 | + if (!$this->input) { |
|
| 128 | + return []; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | $input = is_array($this->input) ? $this->input : $this->input->toArray(); |
| 128 | 132 | |
@@ -147,7 +147,9 @@ |
||
| 147 | 147 | |
| 148 | 148 | foreach ($lines as $index => $line) { |
| 149 | 149 | $line = trim($line); |
| 150 | - if (empty($line)) continue; |
|
| 150 | + if (empty($line)) { |
|
| 151 | + continue; |
|
| 152 | + } |
|
| 151 | 153 | |
| 152 | 154 | $row = str_getcsv($line); |
| 153 | 155 | |
@@ -39,10 +39,12 @@ discard block |
||
| 39 | 39 | $value = &$input[0]; |
| 40 | 40 | $set = array(); |
| 41 | 41 | $set[] = &$value; |
| 42 | - if (is_array($value)) |
|
| 43 | - return Flatted::loop(false, array_keys($value), $input, $set, $value); |
|
| 44 | - if (is_object($value)) |
|
| 45 | - return Flatted::loop(true, Flatted::keys($value), $input, $set, $value); |
|
| 42 | + if (is_array($value)) { |
|
| 43 | + return Flatted::loop(false, array_keys($value), $input, $set, $value); |
|
| 44 | + } |
|
| 45 | + if (is_object($value)) { |
|
| 46 | + return Flatted::loop(true, Flatted::keys($value), $input, $set, $value); |
|
| 47 | + } |
|
| 46 | 48 | return $value; |
| 47 | 49 | } |
| 48 | 50 | |
@@ -77,16 +79,18 @@ discard block |
||
| 77 | 79 | $obj = new ReflectionObject($value); |
| 78 | 80 | $props = $obj->getProperties(); |
| 79 | 81 | $keys = array(); |
| 80 | - foreach ($props as $prop) |
|
| 81 | - $keys[] = $prop->getName(); |
|
| 82 | + foreach ($props as $prop) { |
|
| 83 | + $keys[] = $prop->getName(); |
|
| 84 | + } |
|
| 82 | 85 | return $keys; |
| 83 | 86 | } |
| 84 | 87 | |
| 85 | 88 | private static function loop($obj, $keys, &$input, &$set, &$output) { |
| 86 | 89 | foreach ($keys as $key) { |
| 87 | 90 | $value = $obj ? $output->$key : $output[$key]; |
| 88 | - if ($value instanceof FlattedString) |
|
| 89 | - Flatted::ref($obj, $key, $input[$value->value], $input, $set, $output); |
|
| 91 | + if ($value instanceof FlattedString) { |
|
| 92 | + Flatted::ref($obj, $key, $input[$value->value], $input, $set, $output); |
|
| 93 | + } |
|
| 90 | 94 | } |
| 91 | 95 | return $output; |
| 92 | 96 | } |
@@ -94,8 +98,9 @@ discard block |
||
| 94 | 98 | private static function relate(&$known, &$input, &$value) { |
| 95 | 99 | if (is_string($value) || is_array($value) || is_object($value)) { |
| 96 | 100 | $key = array_search($value, $known->key, true); |
| 97 | - if ($key !== false) |
|
| 98 | - return $known->value[$key]; |
|
| 101 | + if ($key !== false) { |
|
| 102 | + return $known->value[$key]; |
|
| 103 | + } |
|
| 99 | 104 | return Flatted::index($known, $input, $value); |
| 100 | 105 | } |
| 101 | 106 | return $value; |
@@ -105,15 +110,13 @@ discard block |
||
| 105 | 110 | if (is_array($value) && !in_array($value, $set, true)) { |
| 106 | 111 | $set[] = $value; |
| 107 | 112 | $value = Flatted::loop(false, array_keys($value), $input, $set, $value); |
| 108 | - } |
|
| 109 | - elseif (is_object($value) && !in_array($value, $set, true)) { |
|
| 113 | + } elseif (is_object($value) && !in_array($value, $set, true)) { |
|
| 110 | 114 | $set[] = $value; |
| 111 | 115 | $value = Flatted::loop(true, Flatted::keys($value), $input, $set, $value); |
| 112 | 116 | } |
| 113 | 117 | if ($obj) { |
| 114 | 118 | $output->$key = &$value; |
| 115 | - } |
|
| 116 | - else { |
|
| 119 | + } else { |
|
| 117 | 120 | $output[$key] = &$value; |
| 118 | 121 | } |
| 119 | 122 | } |
@@ -130,8 +133,9 @@ discard block |
||
| 130 | 133 | if (is_object($value)) { |
| 131 | 134 | $object = new stdClass; |
| 132 | 135 | $keys = Flatted::keys($value); |
| 133 | - foreach ($keys as $key) |
|
| 134 | - $object->$key = Flatted::relate($known, $input, $value->$key); |
|
| 136 | + foreach ($keys as $key) { |
|
| 137 | + $object->$key = Flatted::relate($known, $input, $value->$key); |
|
| 138 | + } |
|
| 135 | 139 | return $object; |
| 136 | 140 | } |
| 137 | 141 | return $value; |