Passed
Push — master ( 52cf02...273cba )
by Alexander
18:21 queued 14:33
created

SqlsrvPDO::lastInsertId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.1481

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
ccs 2
cts 3
cp 0.6667
crap 2.1481
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\db\mssql;
9
10
/**
11
 * This is an extension of the default PDO class of SQLSRV driver.
12
 * It provides workarounds for improperly implemented functionalities of the SQLSRV driver.
13
 *
14
 * @author Timur Ruziev <[email protected]>
15
 * @since 2.0
16
 */
17
class SqlsrvPDO extends \PDO
18
{
19
    /**
20
     * Returns value of the last inserted ID.
21
     *
22
     * SQLSRV driver implements [[PDO::lastInsertId()]] method but with a single peculiarity:
23
     * when `$sequence` value is a null or an empty string it returns an empty string.
24
     * But when parameter is not specified it works as expected and returns actual
25
     * last inserted ID (like the other PDO drivers).
26
     * @param string|null $sequence the sequence name. Defaults to null.
27
     * @return int last inserted ID value.
28
     */
29 6
    public function lastInsertId($sequence = null)
30
    {
31 6
        return !$sequence ? parent::lastInsertId() : parent::lastInsertId($sequence);
0 ignored issues
show
Bug Best Practice introduced by
The expression return ! $sequence ? par...lastInsertId($sequence) returns the type string which is incompatible with the documented return type integer.
Loading history...
32
    }
33
}
34