PreparedQueryPooler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 42
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPoolerType() 0 4 1
A getClientFromPool() 0 10 1
A createClient() 0 4 1
1
<?php
2
/*
3
 * This file is part of the PommProject/Foundation package.
4
 *
5
 * (c) 2014 - 2017 Grégoire HUBERT <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PommProject\Foundation\PreparedQuery;
11
12
use PommProject\Foundation\Client\ClientPooler;
13
14
/**
15
 * PreparedQueryPooler
16
 *
17
 * Clients pooler for PreparedQuery instances.
18
 *
19
 * @package   Pomm
20
 * @copyright 2014 - 2017 Grégoire HUBERT
21
 * @author    Grégoire HUBERT
22
 * @license   X11 {@link http://opensource.org/licenses/mit-license.php}
23
 * @see       ClientPooler
24
 */
25
class PreparedQueryPooler extends ClientPooler
26
{
27
    /**
28
     * getPoolerType
29
     *
30
     * @see ClientPoolerInterface
31
     */
32
    public function getPoolerType()
33
    {
34
        return 'prepared_query';
35
    }
36
37
    /**
38
     * getClientFromPool
39
     *
40
     * @see    ClientPooler
41
     * @param  string             $sql
42
     * @return PreparedQuery|null
43
     */
44
    protected function getClientFromPool($sql)
45
    {
46
        return $this
47
            ->getSession()
48
            ->getClient(
49
                $this->getPoolerType(),
50
                PreparedQuery::getSignatureFor($sql)
51
            )
52
        ;
53
    }
54
55
    /**
56
     * createClient
57
     *
58
     * @see    ClientPooler
59
     * @param  string $sql SQL query
60
     * @return PreparedQuery
61
     */
62
    public function createClient($sql)
63
    {
64
        return new PreparedQuery($sql);
65
    }
66
}
67