Passed
Push — master ( 313c53...eadb07 )
by Mihail
04:44
created

ActionInviteList::inviteList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 27
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
namespace Apps\Controller\Admin\User;
4
5
use Apps\ActiveRecord\Invite;
6
use Ffcms\Core\Arch\View;
7
use Ffcms\Core\Network\Request;
8
use Ffcms\Core\Network\Response;
9
10
/**
11
 * Trait ActionInvite
12
 * @package Apps\Controller\Admin\User
13
 * @property Request $request
14
 * @property Response $response
15
 * @property View $view
16
 */
17
trait ActionInviteList
18
{
19
20
    public function inviteList(): ?string
21
    {
22
        // init invite object
23
        $record = new Invite();
24
25
        // set current page num and offset
26
        $page = (int)$this->request->query->get('page', 0);
27
        $offset = $page * self::ITEM_PER_PAGE;
0 ignored issues
show
Bug introduced by
The constant Apps\Controller\Admin\Us...viteList::ITEM_PER_PAGE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
28
29
        // prepare pagination data
30
        $pagination = [
31
            'url' => ['user/invitelist'],
32
            'page' => $page,
33
            'step' => self::ITEM_PER_PAGE,
34
            'total' => $record->count()
35
        ];
36
37
        // get invite list
38
        $records = $record->orderBy('id', 'desc')
39
            ->skip($offset)
40
            ->take(self::ITEM_PER_PAGE)
41
            ->get();
42
43
        return $this->view->render('user/invite_list', [
44
            'records' => $records,
45
            'pagination' => $pagination,
46
            'configs' => $this->getConfigs()
0 ignored issues
show
Bug introduced by
It seems like getConfigs() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
            'configs' => $this->/** @scrutinizer ignore-call */ getConfigs()
Loading history...
47
        ]);
48
    }
49
}