Completed
Push — master ( f08c1d...ffbb02 )
by smiley
02:22
created

StatementAbstract::bindValues()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 4
nop 0
1
<?php
2
/**
3
 * Class StatementAbstract
4
 *
5
 * @filesource   StatementAbstract.php
6
 * @created      03.06.2017
7
 * @package      chillerlan\Database\Query
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2017 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\Database\Query;
14
15
use chillerlan\Database\Drivers\DBDriverInterface;
16
17
abstract class StatementAbstract implements StatementInterface{
18
19
	protected $DBDriver;
20
	protected $dialect;
21
	protected $quotes;
22
	protected $limit;
23
	protected $offset;
24
	protected $bindValues = [];
25
26
	public function __construct(DBDriverInterface $DBDriver, string $dialect){
27
		$this->DBDriver = $DBDriver;
28
		$this->dialect  = $dialect;
29
		$this->quotes   = $this->DBDriver->quotes;
0 ignored issues
show
Bug introduced by
Accessing quotes on the interface chillerlan\Database\Drivers\DBDriverInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
30
	}
31
32
	public function sql():string {
33
		return 'NOT IMPLEMENTED';
34
	}
35
36
	public function bindValues():array{
37
38
		if($this->offset){
39
			$this->bindValues[] = $this->offset;
40
		}
41
42
		if($this->limit){
43
			$this->bindValues[] = $this->limit;
44
		}
45
46
		return $this->bindValues;
47
	}
48
49
	public function execute(){
50
51
	}
52
53
	public function quote(string $str):string{
54
		// @todo ...
55
		$str = $this->quotes[0].$str.$this->quotes[1];
56
		return $str;
57
	}
58
59
60
}
61