Completed
Push — master ( 83681b...007d34 )
by Taosikai
12:03
created

TunnelCollection   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A findByInfo() 0 6 1
1
<?php
2
/**
3
 * Spike library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Spike\Client;
7
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Spike\Tunnel\TunnelInterface;
10
11
class TunnelCollection extends ArrayCollection
12
{
13
    /**
14
     * Finds the matching tunnel
15
     * @param array $tunnelInfo
16
     * @return false|TunnelInterface
17
     */
18
    public function findByInfo($tunnelInfo)
19
    {
20
        return $this->filter(function(TunnelInterface $tunnel) use ($tunnelInfo){
21
            return $tunnel->match($tunnelInfo);
22
        })->first();
23
    }
24
}