MqManagermentService::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
3
namespace mcorten87\rabbitmq_api\services;
4
5
6
use mcorten87\rabbitmq_api\MqManagementConfig;
7
use mcorten87\rabbitmq_api\MqManagementFactory;
8
use mcorten87\rabbitmq_api\objects\Host;
9
use mcorten87\rabbitmq_api\objects\Password;
10
use mcorten87\rabbitmq_api\objects\User;
11
12
class MqManagermentService
13
{
14
    /**
15
     * MqManagermentService constructor.
16
     *
17
     * @param MqManagementFactory $factory
18
     */
19
    public function __construct(MqManagementFactory $factory, MqManagementConfig $config)
20
    {
21
        $factory->register($config);
22
        $factory->getConfig();
0 ignored issues
show
Unused Code introduced by
The call to the method mcorten87\rabbitmq_api\M...entFactory::getConfig() 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...
23
    }
24
}
25