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

ericfortmeyer / activity-log / 20521974594

26 Dec 2025 11:53AM UTC coverage: 43.123% (-6.0%) from 49.13%
20521974594

push

github

web-flow
feat: add webhook for deployments (#63)

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

11 of 128 new or added lines in 13 files covered. (8.59%)

1 existing line in 1 file now uncovered.

348 of 807 relevant lines covered (43.12%)

1.33 hits per line

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

60.24
/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
    Storage\NotFound
13
};
14
use EricFortmeyer\ActivityLog\{RemarksForMonth, MonthFilters, CreditHours, Tenant, TimeEntry};
15
use EricFortmeyer\ActivityLog\Services\{
16
    RemarksForMonthService,
17
    CreditHoursService,
18
    TemplateBinder,
19
    TenantService,
20
    TimeEntryService
21
};
22
use EricFortmeyer\ActivityLog\UserInterface\Contexts\{TimeEntriesContext, BadRequestContext};
23
use EricFortmeyer\ActivityLog\Utils\Hasher;
24

25
/**
26
 * Class GetTimeEntries
27
 *
28
 * @package EricFortmeyer\ActivityLog
29
 */
30
final class GetTimeEntries extends AbstractTenantBasedRequestProcessor
31
{
32
    public function __construct(
33
        private readonly string $appVersion,
34
        private readonly TenantService $tenantService,
35
        private readonly TimeEntryService $timeEntryService,
36
        private readonly RemarksForMonthService $remarksForMonthService,
37
        private readonly CreditHoursService $creditHoursService,
38
        private readonly TemplateBinder $templateEngine,
39
        readonly Hasher $hasher,
40
    ) {
41
        parent::__construct($hasher);
2✔
42
    }
43

44
    /**
45
     * Process the request to get all time entries.
46
     *
47
     * @return string The rendered template
48
     */
49
    #[Authorize]
50
    public function process(
51
        #[Model] TimeEntry $timeEntry = new TimeEntry(),
52
        #[Model] MonthFilters $monthFilters = new MonthFilters(),
53
    ): string {
54
        if ($monthFilters->isValid() === false) {
2✔
55
            return $this->templateEngine->apply(
×
56
                "400",
×
57
                new BadRequestContext(message: "Something is wrong with the request.")
×
58
            );
×
59
        }
60

61
        $this->initTenantIfNotExists();
2✔
62

63
        $timeEntry->tenantId ??= $this->getTenantId();
2✔
64
        $month = $monthFilters->getMonth();
2✔
65
        $year = $monthFilters->getYear();
2✔
66
        TimeEntry::setUninitializedValues(timeEntry: $timeEntry, month: $month, year: $year);
2✔
67
        $timeEntries = $this->timeEntryService->getAllByMonth(
2✔
68
            month: $month,
2✔
69
            year: $year,
2✔
70
            tenantId: $this->getTenantId(),
2✔
71
        );
2✔
72
        $remarks = $this->remarksForMonthService->get(RemarksForMonth::getIdFromMonth(
2✔
73
            month: $month,
2✔
74
            year: $year,
2✔
75
            tenantId: $this->getTenantId(),
2✔
76
        ));
2✔
77
        $creditHours = $this->creditHoursService->get(CreditHours::getIdFromMonth(
2✔
78
            month: $month,
2✔
79
            year: $year,
2✔
80
            tenantId: $this->getTenantId(),
2✔
81
        ));
2✔
82
        return $this->templateEngine->apply(
2✔
83
            "index",
2✔
84
            match (true) {
2✔
85
                $remarks instanceof NotFound && $creditHours instanceof NotFound =>
2✔
86
                new TimeEntriesContext(
2✔
87
                    appVersion: $this->appVersion,
2✔
88
                    timeEntries: $timeEntries,
2✔
89
                    tenantId: $this->getTenantId(),
2✔
90
                    currentEntry: $timeEntry,
2✔
91
                    filters: $monthFilters,
2✔
92
                    user: $this->user
2✔
93
                ),
2✔
94
                $creditHours instanceof CreditHours && $remarks instanceof RemarksForMonth =>
2✔
95
                new TimeEntriesContext(
×
NEW
96
                    appVersion: $this->appVersion,
×
97
                    timeEntries: $timeEntries,
×
98
                    tenantId: $this->getTenantId(),
×
99
                    currentEntry: $timeEntry,
×
100
                    filters: $monthFilters,
×
101
                    remarks: $remarks,
×
102
                    creditHours: $creditHours,
×
103
                    user: $this->user
×
104
                ),
×
105
                $creditHours instanceof CreditHours && $remarks instanceof NotFound =>
2✔
106
                new TimeEntriesContext(
×
NEW
107
                    appVersion: $this->appVersion,
×
108
                    timeEntries: $timeEntries,
×
109
                    tenantId: $this->getTenantId(),
×
110
                    currentEntry: $timeEntry,
×
111
                    filters: $monthFilters,
×
112
                    creditHours: $creditHours,
×
113
                    user: $this->user,
×
114
                ),
×
115
                $remarks instanceof RemarksForMonth && $creditHours instanceof NotFound =>
2✔
116
                new TimeEntriesContext(
×
NEW
117
                    appVersion: $this->appVersion,
×
118
                    timeEntries: $timeEntries,
×
119
                    tenantId: $this->getTenantId(),
×
120
                    currentEntry: $timeEntry,
×
121
                    filters: $monthFilters,
×
122
                    remarks: $remarks,
×
123
                    user: $this->user
×
124
                ),
×
125
                default =>
2✔
126
                new TimeEntriesContext(
2✔
127
                    appVersion: $this->appVersion,
2✔
128
                    user: $this->user,
2✔
129
                    tenantId: $this->getTenantId()
2✔
130
                )
2✔
131
            }
2✔
132
        );
2✔
133
    }
134

135
    private function initTenantIfNotExists(): void
136
    {
137
        $tenantId = $this->getTenantId();
2✔
138

139
        if ($this->tenantService->exists($tenantId) === true) {
2✔
140
            return;
×
141
        }
142

143
        $this->tenantService->save(
2✔
144
            new Tenant(["id" => $tenantId])
2✔
145
        );
2✔
146
    }
147
}
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