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

PublicConnectionCollection::findById()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
/**
3
 * Spike library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Spike\Server\TunnelServer;
7
8
use Doctrine\Common\Collections\ArrayCollection;
9
10
class PublicConnectionCollection extends ArrayCollection
11
{
12
    /**
13
     * Finds the connection by its id
14
     * @param string $id
15
     * @return PublicConnection
16
     */
17
    public function findById($id)
18
    {
19
        foreach ($this as $publicConnection) {
20
            if ($publicConnection->getId() == $id) {
21
                return $publicConnection;
22
            }
23
        }
24
        return null;
25
    }
26
}