InfluxOW/laravel_ddd_ecommerce

View on GitHub
app/Components/Purchasable/Http/Resources/CurrencyResource.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace App\Components\Purchasable\Http\Resources;

use Akaunting\Money\Currency;
use Illuminate\Http\Resources\Json\JsonResource;
use JetBrains\PhpStorm\ArrayShape;

final class CurrencyResource extends JsonResource
{
    #[ArrayShape(['name' => 'string', 'abbreviation' => 'string', 'symbol' => 'string'])]
    public function toArray($request): array
    {
        /** @var Currency $currency */
        $currency = $this->resource;

        return [
            'name' => $currency->getName(),
            'abbreviation' => $currency->getCurrency(),
            'symbol' => $currency->getSymbol(),
        ];
    }
}