## Summary - move the Laravel application into `apps/platform` and keep the repository root for orchestration, docs, and tooling - update the local command model, Sail/Docker wiring, runtime paths, and ignore rules around the new platform location - add relocation quickstart/contracts plus focused smoke coverage for bootstrap, command model, routes, and runtime behavior ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/PlatformRelocation` - integrated browser smoke validated `/up`, `/`, `/admin`, `/admin/choose-workspace`, and tenant route semantics for `200`, `403`, and `404` ## Remaining Rollout Checks - validate Dokploy build context and working-directory assumptions against the new `apps/platform` layout - confirm web, queue, and scheduler processes all start from the expected working directory in staging/production - verify no legacy volume mounts or asset-publish paths still point at the old root-level `public/` or `storage/` locations Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #213
133 lines
3.0 KiB
PHP
133 lines
3.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Diff;
|
|
|
|
use BackedEnum;
|
|
use InvalidArgumentException;
|
|
use Stringable;
|
|
|
|
final readonly class DiffRow
|
|
{
|
|
public string $key;
|
|
|
|
public string $label;
|
|
|
|
public DiffRowStatus $status;
|
|
|
|
public mixed $oldValue;
|
|
|
|
public mixed $newValue;
|
|
|
|
public bool $isListLike;
|
|
|
|
/**
|
|
* @var array<int, mixed>
|
|
*/
|
|
public array $addedItems;
|
|
|
|
/**
|
|
* @var array<int, mixed>
|
|
*/
|
|
public array $removedItems;
|
|
|
|
/**
|
|
* @var array<int, mixed>
|
|
*/
|
|
public array $unchangedItems;
|
|
|
|
/**
|
|
* @var array<string, mixed>
|
|
*/
|
|
public array $meta;
|
|
|
|
/**
|
|
* @param array<int, mixed> $addedItems
|
|
* @param array<int, mixed> $removedItems
|
|
* @param array<int, mixed> $unchangedItems
|
|
* @param array<string, mixed> $meta
|
|
*/
|
|
public function __construct(
|
|
string $key,
|
|
string $label,
|
|
DiffRowStatus $status,
|
|
mixed $oldValue = null,
|
|
mixed $newValue = null,
|
|
bool $isListLike = false,
|
|
array $addedItems = [],
|
|
array $removedItems = [],
|
|
array $unchangedItems = [],
|
|
array $meta = [],
|
|
) {
|
|
if (trim($key) === '') {
|
|
throw new InvalidArgumentException('DiffRow key must be a non-empty string.');
|
|
}
|
|
|
|
if (trim($label) === '') {
|
|
throw new InvalidArgumentException('DiffRow label must be a non-empty string.');
|
|
}
|
|
|
|
$this->key = $key;
|
|
$this->label = $label;
|
|
$this->status = $status;
|
|
$this->oldValue = $oldValue;
|
|
$this->newValue = $newValue;
|
|
$this->isListLike = $isListLike;
|
|
$this->addedItems = array_values($addedItems);
|
|
$this->removedItems = array_values($removedItems);
|
|
$this->unchangedItems = array_values($unchangedItems);
|
|
$this->meta = $this->normalizeMeta($meta);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $meta
|
|
* @return array<string, mixed>
|
|
*/
|
|
private function normalizeMeta(array $meta): array
|
|
{
|
|
$normalized = [];
|
|
|
|
foreach ($meta as $key => $value) {
|
|
if (! is_string($key) || trim($key) === '') {
|
|
continue;
|
|
}
|
|
|
|
$normalized[$key] = $this->normalizeMetaValue($value);
|
|
}
|
|
|
|
return $normalized;
|
|
}
|
|
|
|
private function normalizeMetaValue(mixed $value): mixed
|
|
{
|
|
if ($value === null || is_scalar($value)) {
|
|
return $value;
|
|
}
|
|
|
|
if ($value instanceof BackedEnum) {
|
|
return $value->value;
|
|
}
|
|
|
|
if ($value instanceof Stringable) {
|
|
return (string) $value;
|
|
}
|
|
|
|
if (! is_array($value)) {
|
|
return null;
|
|
}
|
|
|
|
$normalized = [];
|
|
|
|
foreach ($value as $key => $item) {
|
|
if (! is_int($key) && ! is_string($key)) {
|
|
continue;
|
|
}
|
|
|
|
$normalized[$key] = $this->normalizeMetaValue($item);
|
|
}
|
|
|
|
return array_is_list($normalized) ? array_values($normalized) : $normalized;
|
|
}
|
|
}
|