DiscussConversationRepository   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 15
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A findPreviousConversation() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Models\Repositories;
6
7
use Xetaravel\Models\DiscussConversation;
8
9
class DiscussConversationRepository
10
{
11
    /**
12
     * Find the previous conversation related to the given conversation.
13
     *
14
     * @param DiscussConversation $conversation
15
     *
16
     * @return DiscussConversation|null
17
     */
18
    public static function findPreviousConversation(DiscussConversation $conversation): ?DiscussConversation
19
    {
20
        return DiscussConversation::where('category_id', $conversation->category->getKey())
21
            ->where('created_at', '<', $conversation->created_at)
22
            ->orderBy('created_at', 'desc')
23
            ->first();
24
    }
25
}
26