Laralabs/get-address-io

View on GitHub
src/Responses/AutocompleteCollectionResponse.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Laralabs\GetAddress\Responses;

use Illuminate\Http\JsonResponse;

class AutocompleteCollectionResponse
{
    protected ?array $suggestions;

    public function __construct(?array $suggestions)
    {
        $this->suggestions = $suggestions;
    }

    public function all(): ?array
    {
        return $this->suggestions;
    }

    public function toArray(): array
    {
        return [
            'suggestions' => $this->suggestions,
        ];
    }

    public function respond(): JsonResponse
    {
        return response()->json($this->toArray());
    }
}