• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NeoIsRecursive / inertia-tempest / 29093027793

10 Jul 2026 12:34PM UTC coverage: 94.821% (-0.2%) from 95.0%
29093027793

push

github

NeoIsRecursive
refactor: remove unused code and fix analysis to have better coverage

18 of 18 new or added lines in 3 files covered. (100.0%)

1 existing line in 1 file now uncovered.

238 of 251 relevant lines covered (94.82%)

15.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.58
/src/Props/ScrollProp.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace NeoIsRecursive\Inertia\Props;
6

7
use Closure;
8
use NeoIsRecursive\Inertia\Concerns\IsCallableProp;
9
use NeoIsRecursive\Inertia\Concerns\IsMergeableProp;
10
use NeoIsRecursive\Inertia\Contracts\CallableProp;
11
use NeoIsRecursive\Inertia\Contracts\MergeableProp;
12
use NeoIsRecursive\Inertia\Contracts\ProvidesScrollMetadata;
13
use Override;
14
use Tempest\Support\Paginator\PaginatedData;
15

16
final class ScrollProp implements CallableProp, MergeableProp
17
{
18
    use IsMergeableProp;
19
    use IsCallableProp;
20

21
    public mixed $resolved = null;
22
    public bool $shouldMerge = true;
23

24
    public function __construct(
25
        public readonly mixed $value,
26
        public string $pageName,
27
        public string $wrapper = 'data',
28
        /** @var ProvidesScrollMetadata|Closure(mixed):ProvidesScrollMetadata|null */
29
        public ProvidesScrollMetadata|Closure|null $metadata = null,
30
    ) {}
1✔
31

32
    public function mergeKey(string|int $key): string|int
33
    {
34
        if (!is_string($key) || $this->wrapper === '') {
1✔
35
            return $key;
×
36
        }
37

38
        return sprintf('%s.%s', $key, $this->wrapper);
1✔
39
    }
40

41
    protected function resolveValue(): mixed
42
    {
43
        if ($this->resolved !== null) {
1✔
44
            return $this->resolved;
1✔
45
        }
46

47
        $this->resolved = $this->resolveCallablePropValue($this->value);
1✔
48

49
        return $this->resolved;
1✔
50
    }
51

52
    /**
53
     * Resolve the scroll metadata provider.
54
     *
55
     * @throws \LogicException
56
     */
57
    protected function resolveMetadataProvider(): ProvidesScrollMetadata
58
    {
59
        if ($this->metadata instanceof ProvidesScrollMetadata) {
1✔
60
            return $this->metadata;
×
61
        }
62

63
        // @mago-expect analyzer:mixed-assignment
64
        $value = $this->resolveValue();
1✔
65

66
        if ($this->metadata === null) {
1✔
67
            $pageName = $this->pageName;
1✔
68

69
            if ($value instanceof PaginatedData) {
1✔
70
                return new class($pageName, $value) implements ProvidesScrollMetadata {
1✔
71
                    public function __construct(
72
                        private string $pageName,
73
                        private PaginatedData $value,
74
                    ) {}
1✔
75

76
                    public function getPageName(): string
77
                    {
78
                        return $this->pageName;
1✔
79
                    }
80

81
                    public function getPreviousPage(): int|string|null
82
                    {
83
                        return $this->value->previousPage;
1✔
84
                    }
85

86
                    public function getNextPage(): int|string|null
87
                    {
88
                        return $this->value->nextPage;
1✔
89
                    }
90

91
                    public function getCurrentPage(): int|string|null
92
                    {
93
                        return $this->value->currentPage;
1✔
94
                    }
95
                };
1✔
96
            }
97
        }
98

99
        $metadata = $this->metadata;
×
100

101
        if (!$metadata instanceof Closure) {
×
102
            throw new \LogicException('Scroll metadata resolver must be a closure or metadata provider.');
×
103
        }
104

UNCOV
105
        return $metadata($value);
×
106
    }
107

108
    /**
109
     * Get the pagination meta information.
110
     *
111
     * @return array{pageName: string, previousPage: int|string|null, nextPage: int|string|null, currentPage: int|string|null}
112
     */
113
    public function metadata(): array
114
    {
115
        $metadataProvider = $this->resolveMetadataProvider();
1✔
116

117
        return [
1✔
118
            'pageName' => $metadataProvider->getPageName(),
1✔
119
            'previousPage' => $metadataProvider->getPreviousPage(),
1✔
120
            'nextPage' => $metadataProvider->getNextPage(),
1✔
121
            'currentPage' => $metadataProvider->getCurrentPage(),
1✔
122
        ];
1✔
123
    }
124

125
    #[Override]
126
    public function __invoke(): mixed
127
    {
128
        // @mago-expect analyzer:mixed-assignment
129
        $value = $this->resolveValue();
1✔
130

131
        if ($value instanceof PaginatedData) {
1✔
132
            return [
1✔
133
                $this->wrapper => $value->data,
1✔
134
            ];
1✔
135
        }
136

137
        return $value;
×
138
    }
139
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc