Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
83.33% covered (warning)
83.33%
5 / 6
80.00% covered (warning)
80.00%
4 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
PromptCommunicationStyleRepository
83.33% covered (warning)
83.33%
5 / 6
80.00% covered (warning)
80.00%
4 / 5
5.12
0.00% covered (danger)
0.00%
0 / 1
 getAll
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 findById
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%
2 / 2
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\Repositories;
4
5use App\Http\Models\PromptCommunicationStyle;
6use App\Http\Repositories\interfaces\IPromptCommunicationStyleRepository;
7use Illuminate\Support\Collection;
8
9/**
10 * Repository for prompt communication style data access operations.
11 *
12 * Handles all database queries related to prompt communication styles,
13 * keeping data access logic separate from business logic.
14 */
15class PromptCommunicationStyleRepository implements IPromptCommunicationStyleRepository
16{
17    /**
18     * Get all prompt communication styles ordered by newest first.
19     *
20     * @return Collection<int, PromptCommunicationStyle> Collection of styles
21     */
22    public function getAll(): Collection
23    {
24        return PromptCommunicationStyle::query()->orderBy('created_at', 'desc')->get();
25    }
26
27    /**
28     * Find a prompt communication style by its ID.
29     *
30     * @param  string  $id  The style ID
31     * @return PromptCommunicationStyle|null The style or null if not found
32     */
33    public function findById(string $id): ?PromptCommunicationStyle
34    {
35        return PromptCommunicationStyle::find($id);
36    }
37
38    /**
39     * Create a new prompt communication style.
40     *
41     * @param  array  $data  The style data
42     * @return PromptCommunicationStyle The created style
43     */
44    public function create(array $data): PromptCommunicationStyle
45    {
46        return PromptCommunicationStyle::create($data);
47    }
48
49    /**
50     * Update an existing prompt communication style.
51     *
52     * @param  PromptCommunicationStyle  $promptCommunicationStyle  The style to update
53     * @param  array  $data  The update data
54     * @return PromptCommunicationStyle The updated style
55     */
56    public function update(PromptCommunicationStyle $promptCommunicationStyle, array $data): PromptCommunicationStyle
57    {
58        $promptCommunicationStyle->update($data);
59
60        return $promptCommunicationStyle->fresh();
61    }
62
63    /**
64     * Delete a prompt communication style.
65     *
66     * @param  PromptCommunicationStyle  $promptCommunicationStyle  The style to delete
67     * @return bool True if deleted successfully
68     */
69    public function delete(PromptCommunicationStyle $promptCommunicationStyle): bool
70    {
71        return $promptCommunicationStyle->delete();
72    }
73}