BurningFlipside /
CommonCode
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | namespace Http; |
||
| 3 | class FlipAdminPage extends LoginRequiredPage |
||
| 4 | { |
||
| 5 | public $is_admin = false; |
||
| 6 | |||
| 7 | public function __construct($title, $adminGroup = 'LDAPAdmins') |
||
| 8 | { |
||
| 9 | parent::__construct($title); |
||
| 10 | $this->is_admin = $this->userIsAdmin($adminGroup); |
||
| 11 | $this->setTemplateName('admin.html'); |
||
| 12 | } |
||
| 13 | |||
| 14 | View Code Duplication | protected function userIsAdmin($adminGroup) |
|
|
0 ignored issues
–
show
|
|||
| 15 | { |
||
| 16 | if($this->user === false || $this->user === null) |
||
|
0 ignored issues
–
show
The property
user does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
| 17 | { |
||
| 18 | return false; |
||
| 19 | } |
||
| 20 | return $this->user->isInGroupNamed($adminGroup); |
||
| 21 | } |
||
| 22 | |||
| 23 | public function isAdmin() |
||
| 24 | { |
||
| 25 | return $this->is_admin; |
||
| 26 | } |
||
| 27 | |||
| 28 | protected function getContent() |
||
| 29 | { |
||
| 30 | if($this->isAdmin() === false) |
||
| 31 | { |
||
| 32 | $this->body = ' |
||
| 33 | <div class="row"> |
||
| 34 | <div class="col-lg-12"> |
||
| 35 | <h1 class="page-header">The current user does not have access rights to the '.$this->content['pageTitle'].' Admin system!</h1> |
||
|
0 ignored issues
–
show
The property
content does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
| 36 | </div> |
||
| 37 | </div>'; |
||
| 38 | } |
||
| 39 | return parent::getContent(); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | /* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
||
| 43 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.