Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
83.33% covered (warning)
83.33%
5 / 6
83.33% covered (warning)
83.33%
5 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
InAppNotificationCampaignService
83.33% covered (warning)
83.33%
5 / 6
83.33% covered (warning)
83.33%
5 / 6
6.17
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAll
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getById
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 create
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 update
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
1<?php
2
3namespace App\Http\Services;
4
5use App\Http\Models\InAppNotificationCampaign;
6use App\Http\Repositories\interfaces\IInAppNotificationCampaignRepository;
7use Illuminate\Database\Eloquent\Collection;
8
9/**
10 * Service for managing in-app notification campaigns.
11 *
12 * Handles business logic for admin CRUD operations on campaigns.
13 */
14class InAppNotificationCampaignService
15{
16    public function __construct(
17        private readonly IInAppNotificationCampaignRepository $campaignRepository
18    ) {}
19
20    /**
21     * Get all campaigns ordered by priority.
22     *
23     * @return Collection<int, InAppNotificationCampaign>
24     */
25    public function getAll(): Collection
26    {
27        return $this->campaignRepository->getAll();
28    }
29
30    /**
31     * Get a single campaign by ID.
32     */
33    public function getById(string $id): ?InAppNotificationCampaign
34    {
35        return $this->campaignRepository->getById($id);
36    }
37
38    /**
39     * Create a new campaign.
40     *
41     * @param  array<string, mixed>  $data  Validated campaign data
42     */
43    public function create(array $data): InAppNotificationCampaign
44    {
45        return $this->campaignRepository->create($data);
46    }
47
48    /**
49     * Update an existing campaign.
50     *
51     * @param  array<string, mixed>  $data  Validated update data
52     */
53    public function update(InAppNotificationCampaign $campaign, array $data): InAppNotificationCampaign
54    {
55        return $this->campaignRepository->update($campaign, $data);
56    }
57
58    /**
59     * Delete a campaign.
60     */
61    public function delete(InAppNotificationCampaign $campaign): bool
62    {
63        return $this->campaignRepository->delete($campaign);
64    }
65}