Failed Conditions
Push — master ( 1b2d37...3f91db )
by Simon
13:21 queued 09:15
created

LogEntryLookup::getLogEntry()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 15
rs 9.9666
c 1
b 0
f 0
cc 2
nc 2
nop 3
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 * ACC Development Team. Please see team.json for a list of contributors.     *
5
 *                                                                            *
6
 * This is free and unencumbered software released into the public domain.    *
7
 * Please see LICENSE.md for the full licencing statement.                    *
8
 ******************************************************************************/
9
10
namespace Waca\Fragments;
11
12
use Waca\DataObjects\Log;
13
use Waca\DataObjects\User;
14
use Waca\Helpers\SearchHelpers\LogSearchHelper;
15
use Waca\PdoDatabase;
16
17
trait LogEntryLookup
18
{
19
    protected function getLogEntry(string $action, User $user, PdoDatabase $database): ?string
20
    {
21
        /** @var Log[] $logs */
22
        $logs = LogSearchHelper::get($database, null)
23
            ->byAction($action)
24
            ->byObjectType('User')
25
            ->byObjectId($user->getId())
26
            ->limit(1)
27
            ->fetch();
28
29
        if (count($logs) > 0) {
30
            return $logs[0]->getComment();
31
        }
32
33
        return null;
34
    }
35
}