Passed
Branch master (7fff21)
by refat
05:12
created

ShowTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 11 1
A row() 0 21 1
1
<?php
2
3
namespace App\Controllers\Admin\User\Traits;
4
5
6
trait ShowTrait
7
{
8
  public function index()
9
  {
10
    $users = $this->load->model('User')->users();
11
    $usersformatted = $this->formatUsers($users);
0 ignored issues
show
Bug introduced by
It seems like formatUsers() 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

11
    /** @scrutinizer ignore-call */ 
12
    $usersformatted = $this->formatUsers($users);
Loading history...
12
    $countries = $this->countries('all', 'name');
0 ignored issues
show
Bug introduced by
It seems like countries() 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

12
    /** @scrutinizer ignore-call */ 
13
    $countries = $this->countries('all', 'name');
Loading history...
13
14
    $context = [
15
      'users' => $usersformatted,
16
      'countries' => $countries,
17
    ];
18
    return $this->view->render('admin/pages/users/users', $context);
19
  }
20
21
  public function row()
22
  {
23
    $id = userId();
24
    $model = $this->load->model('User');
25
    $user = $model->user($id);
26
27
    $user->new = $this->isUserNew($user->registration);
0 ignored issues
show
Bug introduced by
It seems like isUserNew() 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

27
    /** @scrutinizer ignore-call */ 
28
    $user->new = $this->isUserNew($user->registration);
Loading history...
28
    $user->registration = $this->changeFormatDate($user->registration);
0 ignored issues
show
Bug introduced by
It seems like changeFormatDate() 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

28
    /** @scrutinizer ignore-call */ 
29
    $user->registration = $this->changeFormatDate($user->registration);
Loading history...
29
    $user->last_login = $this->changeFormatDate($user->last_login);
30
    $user->last_logout = $this->changeFormatDate($user->last_logout);
31
    $user->birthday = $this->changeFormatDate($user->birthday, ['Y-m-d', 'd M Y']);
32
    $user->country_icon = $this->countries($user->country);
33
34
    $countries = $this->countries('all', 'name');
35
    $countries_options = implode(',', $countries);
36
37
    $context = [
38
      'user' => $user,
39
      'countries_options' => $countries_options,
40
    ];
41
    return $this->view->render('admin/pages/users/user', $context);
42
  }
43
}
44