Completed
Push — master ( 390e4e...b0ec12 )
by Taosikai
12:57
created

TunnelServerCollection   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A filterByControlConnection() 0 6 1
A findByTunnelInfo() 0 6 1
1
<?php
2
/**
3
 * Spike library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Spike\Server;
7
8
use Doctrine\Common\Collections\ArrayCollection;
9
use React\Socket\ConnectionInterface;
10
use Spike\Server\TunnelServer\TunnelServerInterface;
11
12
class TunnelServerCollection extends ArrayCollection
13
{
14
    /**
15
     * @param ConnectionInterface $connection
16
     * @return TunnelServerInterface[]
17
     */
18
    public function filterByControlConnection(ConnectionInterface $connection)
19
    {
20
        return parent::filter(function(TunnelServerInterface $tunnelServer) use ($connection){
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (filter() instead of filterByControlConnection()). Are you sure this is correct? If so, you might want to change this to $this->filter().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
21
            return $tunnelServer->getControlConnection() === $connection;
22
        })->toArray();
23
    }
24
25
    public function findByTunnelInfo($tunnelInfo)
26
    {
27
        return parent::filter(function(TunnelServerInterface $tunnelServer) use ($tunnelInfo){
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (filter() instead of findByTunnelInfo()). Are you sure this is correct? If so, you might want to change this to $this->filter().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
28
            return $tunnelServer->getTunnel()->match($tunnelInfo);
29
        })->first();
30
    }
31
}