2026-08-24 21:06:11 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Modules\Core\Export;
|
|
|
|
|
|
2026-09-16 00:24:18 +03:00
|
|
|
use Closure;
|
|
|
|
|
|
2026-08-24 21:06:11 +03:00
|
|
|
/**
|
|
|
|
|
* One column in a CsvWriter schema: a header label plus a closure that pulls this
|
|
|
|
|
* column's value out of one record. The closure doesn't care what shape a record
|
|
|
|
|
* is — an array, an Eloquent model, a DTO — so the same CsvWriter serves any
|
|
|
|
|
* domain (GDPR export, an admin catalog export, an accounting export) by simply
|
|
|
|
|
* being handed a different column schema and a different row source.
|
|
|
|
|
*/
|
|
|
|
|
final class CsvColumn
|
|
|
|
|
{
|
|
|
|
|
/**
|
2026-09-16 00:24:18 +03:00
|
|
|
* @param Closure(mixed):((string|int|float|null)) $value
|
2026-08-24 21:06:11 +03:00
|
|
|
*/
|
|
|
|
|
public function __construct(
|
|
|
|
|
public readonly string $header,
|
2026-09-16 00:24:18 +03:00
|
|
|
public readonly Closure $value,
|
2026-08-24 21:06:11 +03:00
|
|
|
) {}
|
|
|
|
|
}
|