GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

OnSessionEndEventTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCreate() 11 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * This file is part of Ratchet for CakePHP.
5
 *
6
 ** (c) 2012 - 2015 Cees-Jan Kiewiet
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WyriHaximus\Ratchet\Tests\Event;
13
14
use Phake;
15
use WyriHaximus\Ratchet\Event\OnSessionEndEvent;
16
17 View Code Duplication
class OnSessionEndEventTest extends AbstractEventTest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
18
{
19
    const FQCN = 'WyriHaximus\Ratchet\Event\OnSessionEndEvent';
20
21
    public function testCreate()
22
    {
23
        $realm = 'realm1';
24
        $session = Phake::mock('Thruway\ClientSession');
25
        $transport = Phake::mock('Thruway\Transport\TransportInterface');
0 ignored issues
show
Unused Code introduced by
$transport is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
26
        $event = OnSessionEndEvent::create($realm, $session);
0 ignored issues
show
Documentation introduced by
$session is of type object<Phake_IMock>, but the function expects a object<Thruway\ClientSession>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
        $this->assertSame($session, $event->getSession());
28
        $this->assertSame([
29
            'realm' => $realm,
30
        ], $event->data());
31
    }
32
}
33