Completed
Push — bootstrap4 ( dc7ca1...d74498 )
by Simon
06:19
created

JsUsersAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A executeApiAction() 0 14 2
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca\API\Actions;
10
11
use Waca\API\IJsonApiAction;
12
use Waca\DataObjects\User;
13
use Waca\Helpers\SearchHelpers\UserSearchHelper;
14
use Waca\Tasks\JsonApiPageBase;
15
use Waca\WebRequest;
16
17
class JsUsersAction extends JsonApiPageBase implements IJsonApiAction
18
{
19
    public function executeApiAction()
20
    {
21
        $this->getDatabase();
0 ignored issues
show
Unused Code introduced by
The call to the method Waca\API\Actions\JsUsersAction::getDatabase() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
22
23
        $userSearchHelper = UserSearchHelper::get($this->getDatabase());
24
25
        if (WebRequest::getString('all') === null) {
26
           $userSearchHelper->byStatus(User::STATUS_ACTIVE);
27
28
        }
29
30
        $dataset = $userSearchHelper->fetchColumn('username');
31
        return $dataset;
32
    }
33
}
34