Passed
Push — 5.0.0 ( 9d1037...fbd7bb )
by Fèvre
05:16
created

DiscussConversationRepository::create()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 36
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 21
nc 5
nop 1
dl 0
loc 36
rs 9.584
c 1
b 0
f 0
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