PreparedQueryPooler::getPoolerType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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