# Extension and action examples

<!-- Maintained by scripts/generate-package-readmes.php -->

Use the action functions with records and Data objects supplied by your application.
They pass each argument to the package operation and return its result.

These adapters show container registration. Use the owning package registry when
a contract requires contributor discovery.

Contract adapters wrap an existing implementation. Call their registration function
from your service provider with that implementation; tagged contracts keep their declared tag.
Resolve the backend by its concrete class before registration so the replacement contract
does not resolve itself. Static contract metadata uses one backend class per adapter.

## Contract `Capell\GA4Reports\Contracts\GA4ReportsDataClientInterface`

<!-- example: contract Capell\GA4Reports\Contracts\GA4ReportsDataClientInterface -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\Ga4Reports;

final class GA4ReportsDataClientInterfaceAdapter implements \Capell\GA4Reports\Contracts\GA4ReportsDataClientInterface
{
    public function __construct(private readonly \Capell\GA4Reports\Contracts\GA4ReportsDataClientInterface $backend) {}

    #[\Override]
    public function dailyMetrics(\Capell\GA4Reports\Data\GA4ReportsWindowData $window): array
    {
        return $this->backend->dailyMetrics($window);
    }

    #[\Override]
    public function isConfigured(): bool
    {
        return $this->backend->isConfigured();
    }

    #[\Override]
    public function pageMetrics(\Capell\GA4Reports\Data\GA4ReportsWindowData $window): array
    {
        return $this->backend->pageMetrics($window);
    }
}

function registerGA4ReportsDataClientInterfaceAdapter(\Capell\GA4Reports\Contracts\GA4ReportsDataClientInterface $backend): void
{
    app()->bind(GA4ReportsDataClientInterfaceAdapter::class, static fn (): GA4ReportsDataClientInterfaceAdapter => new GA4ReportsDataClientInterfaceAdapter($backend));
    app()->bind(\Capell\GA4Reports\Contracts\GA4ReportsDataClientInterface::class, GA4ReportsDataClientInterfaceAdapter::class);
}
```