Completed
Push — master ( 77e4e4...2e1347 )
by Beniamin
05:23
created

ParameterManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 31
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\QueryBuilder\Parameter;
13
14
use Phuria\QueryBuilder\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
     * @param string $name
28
     *
29
     * @return QueryParameter
30
     */
31 2
    public function createOrGetParameter($name)
32
    {
33 2
        if (false === array_key_exists($name, $this->params)) {
34 2
            $this->params[$name] = new QueryParameter($name, null);
35 2
        }
36
37 2
        return $this->params[$name];
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43 1
    public function bindStatement(StatementInterface $stmt)
44
    {
45 1
        foreach ($this->params as $param) {
46 1
            $stmt->bindValue($param->getName(), $param->getValue());
47 1
        }
48
    }
49
}