Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
8 / 8
CRAP
100.00% covered (success)
100.00%
1 / 1
CloudflareR2FeedStorage
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
8 / 8
8
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
 store
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 latest
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 exists
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 delete
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 lastModified
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 driver
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace ImovelZapAi\Publishing\Connectors\GroupOlx\Infrastructure\Storage;
6
7use ImovelZapAi\Publishing\Connectors\GroupOlx\Application\Data\FeedStorageVersionData;
8use ImovelZapAi\Publishing\Connectors\GroupOlx\Application\Ports\FeedStorageInterface;
9use ImovelZapAi\Publishing\Connectors\GroupOlx\Domain\Enums\FeedStorageDriver;
10
11/**
12 * Driver Cloudflare R2 do FeedStorage (disco S3-compatible).
13 */
14final class CloudflareR2FeedStorage implements FeedStorageInterface
15{
16    private FeedStorage $inner;
17
18    public function __construct(?FeedStorage $inner = null)
19    {
20        $this->inner = $inner ?? new FeedStorage(
21            driver: FeedStorageDriver::R2,
22            disk: (string) config('publishing.group_olx.storage.r2_disk', 'r2'),
23            pathPrefixTemplate: (string) config(
24                'publishing.group_olx.storage.path_prefix',
25                'publishing/{tenant_id}/group-olx',
26            ),
27            keepVersions: (int) config('publishing.group_olx.storage.keep_versions', 10),
28        );
29    }
30
31    public function store(string $tenantId, string $xml): FeedStorageVersionData
32    {
33        return $this->inner->store($tenantId, $xml);
34    }
35
36    public function latest(string $tenantId, bool $withXml = true): ?FeedStorageVersionData
37    {
38        return $this->inner->latest($tenantId, $withXml);
39    }
40
41    public function get(string $tenantId): ?string
42    {
43        return $this->inner->get($tenantId);
44    }
45
46    public function exists(string $tenantId): bool
47    {
48        return $this->inner->exists($tenantId);
49    }
50
51    public function delete(string $tenantId): void
52    {
53        $this->inner->delete($tenantId);
54    }
55
56    public function lastModified(string $tenantId): ?int
57    {
58        return $this->inner->lastModified($tenantId);
59    }
60
61    public function driver(): FeedStorageDriver
62    {
63        return FeedStorageDriver::R2;
64    }
65}