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.

InternalClientTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 88.89 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testOnSessionStart() 16 16 1
A testOnSessionEnd() 16 16 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
namespace WyriHaximus\Ratchet\Tests\Websocket;
4
5
use Cake\Event\EventManager;
6
use Phake;
7
use WyriHaximus\Ratchet\Event\OnSessionEndEvent;
8
use WyriHaximus\Ratchet\Event\OnSessionStartEvent;
9
use WyriHaximus\Ratchet\Websocket\InternalClient;
10
11
class InternalClientTest extends \PHPUnit_Framework_TestCase
12
{
13 View Code Duplication
    public function testOnSessionStart()
0 ignored issues
show
Duplication introduced by
This method 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...
14
    {
15
        $callbackFired = false;
16
        $func = function ($event) use (&$callbackFired) {
17
            $this->assertInstanceOf('WyriHaximus\Ratchet\Event\OnSessionStartEvent', $event);
18
            $callbackFired = true;
19
        };
20
21
        $client = new InternalClient('test1');
22
23
        EventManager::instance()->on(OnSessionStartEvent::EVENT, $func);
24
        $client->onSessionStart(Phake::mock('Thruway\ClientSession'), Phake::mock('Thruway\Transport\TransportInterface'));
0 ignored issues
show
Documentation introduced by
\Phake::mock('Thruway\\ClientSession') 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...
Documentation introduced by
\Phake::mock('Thruway\\T...t\\TransportInterface') is of type object<Phake_IMock>, but the function expects a object<Thruway\Transport\TransportInterface>.

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...
25
        EventManager::instance()->off(OnSessionStartEvent::EVENT, $func);
26
27
        $this->assertTrue($callbackFired);
28
    }
29
30 View Code Duplication
    public function testOnSessionEnd()
0 ignored issues
show
Duplication introduced by
This method 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...
31
    {
32
        $callbackFired = false;
33
        $func = function ($event) use (&$callbackFired) {
34
            $this->assertInstanceOf('WyriHaximus\Ratchet\Event\OnSessionEndEvent', $event);
35
            $callbackFired = true;
36
        };
37
38
        $client = new InternalClient('test1');
39
40
        EventManager::instance()->on(OnSessionEndEvent::EVENT, $func);
41
        $client->onSessionEnd(Phake::mock('Thruway\ClientSession'));
0 ignored issues
show
Documentation introduced by
\Phake::mock('Thruway\\ClientSession') 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...
42
        EventManager::instance()->off(OnSessionEndEvent::EVENT, $func);
43
44
        $this->assertTrue($callbackFired);
45
    }
46
}
47