Completed
Push — master ( 47c098...6c95d6 )
by smiley
02:23
created

StatementAbstract::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
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
23
	public function __construct(DBDriverInterface $DBDriver, string $dialect){
24
		$this->DBDriver = $DBDriver;
25
		$this->dialect  = $dialect;
26
		$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...
27
	}
28
29
	public function sql():string {
30
		return 'NOT IMPLEMENTED';
31
	}
32
33
	public function execute(){
34
35
	}
36
37
	public function quote(string $str):string{
38
		// @todo ...
39
		$str = $this->quotes[0].$str.$this->quotes[1];
40
		return $str;
41
	}
42
43
}
44