Completed
Push — master ( 8089c4...ec27e4 )
by smiley
02:29
created

StatementAbstract::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
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 ...
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
55
#		$str = $this->quotes[0].$str.$this->quotes[1];
56
		return $str;
57
	}
58
59
	protected function getStatementClass(string $name){
60
		$class = $this->dialect.'\\'.$name;
61
		return new $class($this->DBDriver, $this->dialect);
62
63
	}
64
65
}
66