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

TunnelServerCollection::findByTunnelInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 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
}