@@ -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 | |
@@ -19,34 +19,34 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | class FlattedString { |
| 22 | - public $value = ''; |
|
| 23 | - public function __construct($value) { |
|
| 22 | + public $value = ''; |
|
| 23 | + public function __construct($value) { |
|
| 24 | 24 | $this->value = $value; |
| 25 | - } |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | class Flatted { |
| 29 | 29 | |
| 30 | - // public utilities |
|
| 31 | - public static function parse($json, $assoc = false, $depth = 512, $options = 0) { |
|
| 30 | + // public utilities |
|
| 31 | + public static function parse($json, $assoc = false, $depth = 512, $options = 0) { |
|
| 32 | 32 | $input = array_map( |
| 33 | - 'Flatted::asString', |
|
| 34 | - array_map( |
|
| 33 | + 'Flatted::asString', |
|
| 34 | + array_map( |
|
| 35 | 35 | 'Flatted::wrap', |
| 36 | 36 | json_decode($json, $assoc, $depth, $options) |
| 37 | - ) |
|
| 37 | + ) |
|
| 38 | 38 | ); |
| 39 | 39 | $value = &$input[0]; |
| 40 | 40 | $set = array(); |
| 41 | 41 | $set[] = &$value; |
| 42 | 42 | if (is_array($value)) |
| 43 | - return Flatted::loop(false, array_keys($value), $input, $set, $value); |
|
| 43 | + return Flatted::loop(false, array_keys($value), $input, $set, $value); |
|
| 44 | 44 | if (is_object($value)) |
| 45 | - return Flatted::loop(true, Flatted::keys($value), $input, $set, $value); |
|
| 45 | + return Flatted::loop(true, Flatted::keys($value), $input, $set, $value); |
|
| 46 | 46 | return $value; |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public static function stringify($value, $options = 0, $depth = 512) { |
|
| 49 | + public static function stringify($value, $options = 0, $depth = 512) { |
|
| 50 | 50 | $known = new stdClass; |
| 51 | 51 | $known->key = array(); |
| 52 | 52 | $known->value = array(); |
@@ -54,103 +54,103 @@ discard block |
||
| 54 | 54 | $output = array(); |
| 55 | 55 | $i = intval(Flatted::index($known, $input, $value)); |
| 56 | 56 | while ($i < count($input)) { |
| 57 | - $output[$i] = Flatted::transform($known, $input, $input[$i]); |
|
| 58 | - $i++; |
|
| 57 | + $output[$i] = Flatted::transform($known, $input, $input[$i]); |
|
| 58 | + $i++; |
|
| 59 | 59 | } |
| 60 | 60 | return json_encode($output, $options, $depth); |
| 61 | - } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // private helpers |
|
| 64 | - private static function asString($value) { |
|
| 63 | + // private helpers |
|
| 64 | + private static function asString($value) { |
|
| 65 | 65 | return $value instanceof FlattedString ? $value->value : $value; |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - private static function index(&$known, &$input, &$value) { |
|
| 68 | + private static function index(&$known, &$input, &$value) { |
|
| 69 | 69 | $input[] = &$value; |
| 70 | 70 | $index = strval(count($input) - 1); |
| 71 | 71 | $known->key[] = &$value; |
| 72 | 72 | $known->value[] = &$index; |
| 73 | 73 | return $index; |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - private static function keys(&$value) { |
|
| 76 | + private static function keys(&$value) { |
|
| 77 | 77 | $obj = new ReflectionObject($value); |
| 78 | 78 | $props = $obj->getProperties(); |
| 79 | 79 | $keys = array(); |
| 80 | 80 | foreach ($props as $prop) |
| 81 | - $keys[] = $prop->getName(); |
|
| 81 | + $keys[] = $prop->getName(); |
|
| 82 | 82 | return $keys; |
| 83 | - } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - private static function loop($obj, $keys, &$input, &$set, &$output) { |
|
| 85 | + private static function loop($obj, $keys, &$input, &$set, &$output) { |
|
| 86 | 86 | foreach ($keys as $key) { |
| 87 | - $value = $obj ? $output->$key : $output[$key]; |
|
| 88 | - if ($value instanceof FlattedString) |
|
| 87 | + $value = $obj ? $output->$key : $output[$key]; |
|
| 88 | + if ($value instanceof FlattedString) |
|
| 89 | 89 | Flatted::ref($obj, $key, $input[$value->value], $input, $set, $output); |
| 90 | 90 | } |
| 91 | 91 | return $output; |
| 92 | - } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - private static function relate(&$known, &$input, &$value) { |
|
| 94 | + private static function relate(&$known, &$input, &$value) { |
|
| 95 | 95 | if (is_string($value) || is_array($value) || is_object($value)) { |
| 96 | - $key = array_search($value, $known->key, true); |
|
| 97 | - if ($key !== false) |
|
| 96 | + $key = array_search($value, $known->key, true); |
|
| 97 | + if ($key !== false) |
|
| 98 | 98 | return $known->value[$key]; |
| 99 | - return Flatted::index($known, $input, $value); |
|
| 99 | + return Flatted::index($known, $input, $value); |
|
| 100 | 100 | } |
| 101 | 101 | return $value; |
| 102 | - } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - private static function ref($obj, &$key, &$value, &$input, &$set, &$output) { |
|
| 104 | + private static function ref($obj, &$key, &$value, &$input, &$set, &$output) { |
|
| 105 | 105 | if (is_array($value) && !in_array($value, $set, true)) { |
| 106 | - $set[] = $value; |
|
| 107 | - $value = Flatted::loop(false, array_keys($value), $input, $set, $value); |
|
| 106 | + $set[] = $value; |
|
| 107 | + $value = Flatted::loop(false, array_keys($value), $input, $set, $value); |
|
| 108 | 108 | } |
| 109 | 109 | elseif (is_object($value) && !in_array($value, $set, true)) { |
| 110 | - $set[] = $value; |
|
| 111 | - $value = Flatted::loop(true, Flatted::keys($value), $input, $set, $value); |
|
| 110 | + $set[] = $value; |
|
| 111 | + $value = Flatted::loop(true, Flatted::keys($value), $input, $set, $value); |
|
| 112 | 112 | } |
| 113 | 113 | if ($obj) { |
| 114 | - $output->$key = &$value; |
|
| 114 | + $output->$key = &$value; |
|
| 115 | 115 | } |
| 116 | 116 | else { |
| 117 | - $output[$key] = &$value; |
|
| 117 | + $output[$key] = &$value; |
|
| 118 | + } |
|
| 118 | 119 | } |
| 119 | - } |
|
| 120 | 120 | |
| 121 | - private static function transform(&$known, &$input, &$value) { |
|
| 121 | + private static function transform(&$known, &$input, &$value) { |
|
| 122 | 122 | if (is_array($value)) { |
| 123 | - return array_map( |
|
| 123 | + return array_map( |
|
| 124 | 124 | function ($value) use(&$known, &$input) { |
| 125 | - return Flatted::relate($known, $input, $value); |
|
| 125 | + return Flatted::relate($known, $input, $value); |
|
| 126 | 126 | }, |
| 127 | 127 | $value |
| 128 | - ); |
|
| 128 | + ); |
|
| 129 | 129 | } |
| 130 | 130 | if (is_object($value)) { |
| 131 | - $object = new stdClass; |
|
| 132 | - $keys = Flatted::keys($value); |
|
| 133 | - foreach ($keys as $key) |
|
| 131 | + $object = new stdClass; |
|
| 132 | + $keys = Flatted::keys($value); |
|
| 133 | + foreach ($keys as $key) |
|
| 134 | 134 | $object->$key = Flatted::relate($known, $input, $value->$key); |
| 135 | - return $object; |
|
| 135 | + return $object; |
|
| 136 | 136 | } |
| 137 | 137 | return $value; |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - private static function wrap($value) { |
|
| 140 | + private static function wrap($value) { |
|
| 141 | 141 | if (is_string($value)) { |
| 142 | - return new FlattedString($value); |
|
| 142 | + return new FlattedString($value); |
|
| 143 | 143 | } |
| 144 | 144 | if (is_array($value)) { |
| 145 | - return array_map('Flatted::wrap', $value); |
|
| 145 | + return array_map('Flatted::wrap', $value); |
|
| 146 | 146 | } |
| 147 | 147 | if (is_object($value)) { |
| 148 | - $keys = Flatted::keys($value); |
|
| 149 | - foreach ($keys as $key) { |
|
| 148 | + $keys = Flatted::keys($value); |
|
| 149 | + foreach ($keys as $key) { |
|
| 150 | 150 | $value->$key = self::wrap($value->$key); |
| 151 | - } |
|
| 151 | + } |
|
| 152 | 152 | } |
| 153 | 153 | return $value; |
| 154 | - } |
|
| 154 | + } |
|
| 155 | 155 | } |
| 156 | 156 | ?> |
| 157 | 157 | \ No newline at end of file |
@@ -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; |
@@ -454,8 +454,8 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | try { |
| 456 | 456 | return Vite::useBuildDirectory(config('admin.vite.build_path', 'build')) |
| 457 | - ->withEntryPoints(static::$viteAssets['css']) |
|
| 458 | - ->toHtml(); |
|
| 457 | + ->withEntryPoints(static::$viteAssets['css']) |
|
| 458 | + ->toHtml(); |
|
| 459 | 459 | } catch (\Exception $e) { |
| 460 | 460 | // Fallback to legacy assets if Vite fails |
| 461 | 461 | return ''; |
@@ -475,8 +475,8 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | try { |
| 477 | 477 | return Vite::useBuildDirectory(config('admin.vite.build_path', 'build')) |
| 478 | - ->withEntryPoints(static::$viteAssets['js']) |
|
| 479 | - ->toHtml(); |
|
| 478 | + ->withEntryPoints(static::$viteAssets['js']) |
|
| 479 | + ->toHtml(); |
|
| 480 | 480 | } catch (\Exception $e) { |
| 481 | 481 | // Fallback to legacy assets if Vite fails |
| 482 | 482 | return ''; |