Completed
Push — master ( 8f800b...a10bf5 )
by Biao
03:46
created

CoroutineMySQL::query()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Hhxsv5\LaravelS\Illuminate\Database;
4
5
use Illuminate\Database\QueryException;
6
use Swoole\Coroutine\MySQL as SwooleMySQL;
7
8
class CoroutineMySQL
9
{
10
    protected $coMySQL;
11
12
    public function __construct()
13
    {
14
        $this->coMySQL = new SwooleMySQL();
15
    }
16
17
    public function connect(array $serverInfo)
18
    {
19
        $this->coMySQL->connect($serverInfo);
20
    }
21
22
    public function prepare($sql)
23
    {
24
        $oldStatement = $this->coMySQL->prepare($sql);
25
        if ($oldStatement === false) {
0 ignored issues
show
introduced by
The condition $oldStatement === false is always false.
Loading history...
26
            throw new QueryException($sql, [], new \Exception($this->coMySQL->error, $this->coMySQL->errno));
27
        }
28
        return new CoroutineMySQLStatement($oldStatement);
29
    }
30
31
    public function beginTransaction()
32
    {
33
        return $this->coMySQL->begin();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->coMySQL->begin() targeting Swoole\Coroutine\Mysql::begin() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
34
    }
35
36
    public function commit()
37
    {
38
        return $this->coMySQL->commit();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->coMySQL->commit() targeting Swoole\Coroutine\Mysql::commit() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
39
    }
40
41
    public function rollBack()
42
    {
43
        return $this->coMySQL->rollback();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->coMySQL->rollback() targeting Swoole\Coroutine\Mysql::rollback() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
44
    }
45
46
    public function query($sql, $timeout = 0.0)
47
    {
48
        return $this->coMySQL->query($sql, $timeout);
49
    }
50
51
    public function lastInsertId()
52
    {
53
        return $this->coMySQL->insert_id;
54
    }
55
56
    public function rowCount()
57
    {
58
        return $this->coMySQL->affected_rows;
59
    }
60
}