Completed
Push — master ( b54f87...bde51f )
by Beniamin
04:50
created

ParameterManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 29
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createOrGetParameter() 0 8 2
A bindStatement() 0 6 2
1
<?php
2
3
/**
4
 * This file is part of Phuria SQL Builder package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\SQLBuilder\Parameter;
13
14
use Phuria\SQLBuilder\Statement\StatementInterface;
15
16
/**
17
 * @author Beniamin Jonatan Šimko <[email protected]>
18
 */
19
class ParameterManager implements ParameterManagerInterface
20
{
21
    /**
22
     * @var QueryParameter[] $params
23
     */
24
    private $params = [];
25
26
    /**
27
     * @inheritdoc
28
     */
29 3
    public function createOrGetParameter($name)
30
    {
31 3
        if (false === array_key_exists($name, $this->params)) {
32 3
            $this->params[$name] = new QueryParameter($name);
33 3
        }
34
35 3
        return $this->params[$name];
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41 4
    public function bindStatement(StatementInterface $stmt)
42
    {
43 4
        foreach ($this->params as $param) {
44 3
            $stmt->bindValue($param->getName(), $param->getValue());
45 4
        }
46
    }
47
}