Passed
Push — master ( 527670...666a8e )
by Sergei
06:51 queued 02:16
created

Command   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 22
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A showDatabases() 0 7 1
A insertWithReturningPks() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mssql;
6
7
use Yiisoft\Db\Driver\Pdo\AbstractPdoCommand;
8
9
/**
10
 * Implements a database command that can be executed against a PDO (PHP Data Object) database connection for MSSQL
11
 * Server.
12
 */
13
final class Command extends AbstractPdoCommand
14
{
15 10
    public function insertWithReturningPks(string $table, array $columns): bool|array
16
    {
17 10
        if (empty($this->db->getSchema()->getTableSchema($table)?->getPrimaryKey())) {
18 1
            if (parent::insert($table, $columns)->execute() === 0) {
19
                return false;
20
            }
21
22 1
            return [];
23
        }
24
25 9
        return parent::insertWithReturningPks($table, $columns);
26
    }
27
28 1
    public function showDatabases(): array
29
    {
30 1
        $sql = <<<SQL
31
        SELECT [name] FROM [sys].[databases] WHERE [name] NOT IN ('master', 'tempdb', 'model', 'msdb')
32 1
        SQL;
33
34 1
        return $this->setSql($sql)->queryColumn();
35
    }
36
}
37