Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
user
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 get_priority
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 query
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 *
4 * This file is part of the phpBB Forum Software package.
5 *
6 * @copyright (c) phpBB Limited <https://www.phpbb.com>
7 * @license       GNU General Public License, version 2 (GPL-2.0)
8 *
9 * For full copyright and license information, please see
10 * the docs/CREDITS.txt file.
11 *
12 */
13
14namespace phpbb\mention\source;
15
16class user extends base_user
17{
18    /**
19     * {@inheritdoc}
20     */
21    public function get_priority(array $row): int
22    {
23        /*
24         * Presence in array with all names for this type should not increase the priority
25         * Otherwise names will not be properly sorted because we fetch them in batches
26         * and the name from 'special' source can be absent from the array with all names
27         * and therefore it will appear lower than needed
28         */
29        return 0;
30    }
31
32    /**
33     * {@inheritdoc}
34     */
35    protected function query(string $keyword, int $topic_id): string
36    {
37        return $this->db->sql_build_query('SELECT', [
38            'SELECT'    => 'u.username_clean, u.user_id',
39            'FROM'        => [
40                USERS_TABLE => 'u',
41            ],
42            'WHERE'        => $this->db->sql_in_set('u.user_type', [USER_NORMAL, USER_FOUNDER]) . '
43                AND u.username_clean ' . $this->db->sql_like_expression($keyword . $this->db->get_any_char()),
44            'ORDER_BY'    => 'u.user_lastvisit DESC'
45        ]);
46    }
47}