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

ericfortmeyer / activity-log / 20361289242

19 Dec 2025 05:54AM UTC coverage: 56.627% (+4.3%) from 52.31%
20361289242

push

github

ericfortmeyer
test: remove code coverage attributes

Signed-off-by: Eric Fortmeyer <e.fortmeyer01@gmail.com>

329 of 581 relevant lines covered (56.63%)

1.68 hits per line

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

62.67
/src/Http/RequestProcessors/GetTimeEntries.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace EricFortmeyer\ActivityLog\Http\RequestProcessors;
6

7
use Phpolar\Phpolar\Auth\{
8
    Authorize
9
};
10
use Phpolar\{
11
    Model\Model,
12
    PurePhp\TemplateEngine,
13
    PurePhp\HtmlSafeContext,
14
    Storage\NotFound
15
};
16
use EricFortmeyer\ActivityLog\{RemarksForMonth, MonthFilters, CreditHours, TimeEntry};
17
use EricFortmeyer\ActivityLog\Services\{RemarksForMonthService, CreditHoursService, TimeEntryService};
18
use EricFortmeyer\ActivityLog\UserInterface\Contexts\{TimeEntriesContext, BadRequestContext};
19
use EricFortmeyer\ActivityLog\Utils\Hasher;
20

21
/**
22
 * Class GetTimeEntries
23
 *
24
 * @package EricFortmeyer\ActivityLog
25
 */
26
final class GetTimeEntries extends AbstractTenantBasedRequestProcessor
27
{
28
    public function __construct(
29
        private readonly TimeEntryService $timeEntryService,
30
        private readonly RemarksForMonthService $remarksForMonthService,
31
        private readonly CreditHoursService $creditHoursService,
32
        private readonly TemplateEngine $templateEngine,
33
        readonly Hasher $hasher,
34
    ) {
35
        parent::__construct($hasher);
2✔
36
    }
37

38
    /**
39
     * Process the request to get all time entries.
40
     *
41
     * @return string The rendered template
42
     */
43
    #[Authorize]
44
    public function process(
45
        #[Model] TimeEntry $timeEntry = new TimeEntry(),
46
        #[Model] MonthFilters $monthFilters = new MonthFilters(),
47
    ): string {
48
        if ($monthFilters->isValid() === false) {
2✔
49
            return (string) $this->templateEngine->apply(
×
50
                "400",
×
51
                new HtmlSafeContext(
×
52
                    new BadRequestContext(message: "Something is wrong with the request.")
×
53
                )
×
54
            );
×
55
        }
56
        $timeEntry->tenantId ??= $this->getTenantId();
2✔
57
        $month = $monthFilters->getMonth();
2✔
58
        $year = $monthFilters->getYear();
2✔
59
        TimeEntry::setUninitializedValues(timeEntry: $timeEntry, month: $month, year: $year);
2✔
60
        $timeEntries = $this->timeEntryService->getAllByMonth(
2✔
61
            month: $month,
2✔
62
            year: $year,
2✔
63
            tenantId: $this->getTenantId(),
2✔
64
        );
2✔
65
        $remarks = $this->remarksForMonthService->get(RemarksForMonth::getIdFromMonth(
2✔
66
            month: $month,
2✔
67
            year: $year,
2✔
68
            tenantId: $this->getTenantId(),
2✔
69
        ));
2✔
70
        $creditHours = $this->creditHoursService->get(CreditHours::getIdFromMonth(
2✔
71
            month: $month,
2✔
72
            year: $year,
2✔
73
            tenantId: $this->getTenantId(),
2✔
74
        ));
2✔
75
        return (string) $this->templateEngine->apply(
2✔
76
            "index",
2✔
77
            new HtmlSafeContext(
2✔
78
                $this->getContext(
2✔
79
                    timeEntries: $timeEntries,
2✔
80
                    timeEntry: $timeEntry,
2✔
81
                    monthFilters: $monthFilters,
2✔
82
                    remarks: $remarks,
2✔
83
                    creditHours: $creditHours,
2✔
84
                )
2✔
85
            ),
2✔
86
        );
2✔
87
    }
88

89
    /**
90
     * @param TimeEntry[] $timeEntries
91
     */
92
    private function getContext(
93
        array $timeEntries,
94
        TimeEntry $timeEntry,
95
        MonthFilters $monthFilters,
96
        RemarksForMonth| NotFound $remarks,
97
        CreditHours|NotFound $creditHours,
98
    ): TimeEntriesContext {
99
        return match (true) {
2✔
100
            $remarks instanceof NotFound && $creditHours instanceof NotFound =>
2✔
101
            new TimeEntriesContext(
2✔
102
                timeEntries: $timeEntries,
2✔
103
                currentEntry: $timeEntry,
2✔
104
                filters: $monthFilters,
2✔
105
                user: $this->user
2✔
106
            ),
2✔
107
            $creditHours instanceof CreditHours && $remarks instanceof RemarksForMonth =>
2✔
108
            new TimeEntriesContext(
×
109
                timeEntries: $timeEntries,
×
110
                currentEntry: $timeEntry,
×
111
                filters: $monthFilters,
×
112
                remarks: $remarks,
×
113
                creditHours: $creditHours,
×
114
                user: $this->user
×
115
            ),
×
116
            $creditHours instanceof CreditHours && $remarks instanceof NotFound =>
2✔
117
            new TimeEntriesContext(
×
118
                timeEntries: $timeEntries,
×
119
                currentEntry: $timeEntry,
×
120
                filters: $monthFilters,
×
121
                creditHours: $creditHours,
×
122
                user: $this->user,
×
123
            ),
×
124
            $remarks instanceof RemarksForMonth && $creditHours instanceof NotFound =>
2✔
125
            new TimeEntriesContext(
×
126
                timeEntries: $timeEntries,
×
127
                currentEntry: $timeEntry,
×
128
                filters: $monthFilters,
×
129
                remarks: $remarks,
×
130
                user: $this->user
×
131
            ),
×
132
            default =>
2✔
133
            new TimeEntriesContext(user: $this->user)
2✔
134
        };
2✔
135
    }
136
}
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