<?php
// Sample PHP 8 script — samplefiles.com
declare(strict_types=1);

final class Customer
{
    public function __construct(
        public readonly int $id,
        public readonly string $name,
        public readonly float $balance,
    ) {}

    public function isVip(): bool
    {
        return $this->balance >= 10_000;
    }
}

function totalBalance(array $customers): float
{
    return array_sum(array_map(fn (Customer $c) => $c->balance, $customers));
}

$customers = [new Customer(1, 'Ada', 12_500), new Customer(2, 'Grace', 830.5), new Customer(3, 'Linus', 10_000)];
foreach ($customers as $c) {
    printf("%-6s %10.2f %s\n", $c->name, $c->balance, $c->isVip() ? 'VIP' : '');
}
printf("Total: %.2f\n", totalBalance($customers));
