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

TunnelCollection::findByInfo()   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\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
}