Completed
Push — master ( 0eeb04...4002ae )
by Oscar
02:31
created

Query   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 38
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
__invoke() 0 1 ?
__toString() 0 1 ?
A run() 0 4 1
1
<?php
2
3
namespace SimpleCrud\Queries;
4
5
use SimpleCrud\Table;
6
7
/**
8
 * Base class used by all queries.
9
 */
10
abstract class Query
11
{
12
    protected $table;
13
14
    /**
15
     * Constructor.
16
     *
17
     * @param Table $table
18
     */
19
    public function __construct(Table $table)
20
    {
21
        $this->table = $table;
22
    }
23
24
    /**
25
     * Run the query and return the statement object.
26
     *
27
     * @return PDOStatement
28
     */
29
    abstract public function __invoke();
30
31
    /**
32
     * Build and return the query.
33
     *
34
     * @return string
35
     */
36
    abstract public function __toString();
37
38
    /**
39
     * Executes the query and returns true if it's ok.
40
     * 
41
     * @return mixed
42
     */
43
    public function run()
44
    {
45
        return $this->__invoke();
46
    }
47
}
48