Passed
Push — master ( c5754d...f173b7 )
by Darío
05:12
created

UserConnectionsTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getNextId() 0 11 2
1
<?php
2
3
namespace Workarea\Model;
4
5
use Drone\Db\TableGateway\TableGateway;
6
7
class UserConnectionsTable extends TableGateway
8
{
9
    /**
10
     * Returns the max primary key to add
11
     *
12
     * @return string
13
     */
14
    public function getNextId()
15
    {
16
        $table = $this->getEntity()->getTableName();
17
18
        $sql = "SELECT MAX(USER_CONN_ID) USER_CONN_ID FROM $table";
19
20
        $this->getDriver()->getDb()->execute($sql);
21
        $rowset = $this->getDriver()->getDb()->getArrayResult();
22
        $row = array_shift($rowset);
23
24
        return is_null($row["USER_CONN_ID"]) ? 1 : (integer) $row["USER_CONN_ID"] + 1;
25
    }
26
}