GatewayParameterList::clear()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * Copyright notice:
5
 * (c) Copyright 2017 RocketGate
6
 * All rights reserved.
7
 *
8
 * The copyright notice must not be removed without specific, prior
9
 * written permission from RocketGate.
10
 *
11
 * This software is protected as an unpublished work under the U.S. copyright
12
 * laws. The above copyright notice is not intended to effect a publication of
13
 * this work.
14
 * This software is the confidential and proprietary information of RocketGate.
15
 * Neither the binaries nor the source code may be redistributed without prior
16
 * written permission from RocketGate.
17
 *
18
 * The software is provided "as-is" and without warranty of any kind, express, implied
19
 * or otherwise, including without limitation, any warranty of merchantability or fitness
20
 * for a particular purpose.  In no event shall RocketGate be liable for any direct,
21
 * special, incidental, indirect, consequential or other damages of any kind, or any damages
22
 * whatsoever arising out of or in connection with the use or performance of this software,
23
 * including, without limitation, damages resulting from loss of use, data or profits, and
24
 * whether or not advised of the possibility of damage, regardless of the theory of liability.
25
 */
26
27
namespace RocketGate\Sdk;
28
29
class GatewayParameterList extends GatewayAbstract
30
{
31
    /**
32
     * @var array
33
     */
34
    public $params;
35
36
    /**
37
     * GatewayParameterList constructor.
38
     */
39
    public function __construct()
40
    {
41
        $this->params = [];
42
    }
43
44
    public function reset()
45
    {
46
        $this->params = [];
47
    }
48
49
    /**
50
     * Return the value associated with a key.
51
     *
52
     * @param $key
53
     *
54
     * @return mixed|null|string
55
     */
56
    public function get(string $key)
57
    {
58
        return isset($this->params[$key]) ? trim($this->params[$key]) : null;
59
    }
60
61
    /**
62
     * Set the value associated with a key.
63
     *
64
     * @param string $key
65
     * @param mixed  $value
66
     */
67
    public function set(string $key, $value)
68
    {
69
        $this->clear($key);
70
        if (is_float($value)) {
71
            $value = str_replace(',', '.', (string) $value);
72
        }
73
        $this->params[$key] = $value;
74
    }
75
76
    /**
77
     * Remove a key value.
78
     *
79
     * @param $key
80
     *
81
     * @return mixed|null|string
82
     */
83
    public function clear($key)
84
    {
85
        if (isset($this->params[$key])) {
86
            unset($this->params[$key]);
87
        }
88
    }
89
}
90