Passed
Push — master ( 700b0f...aafb0a )
by Björn
18:25 queued 10s
created

Settings   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 226
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 18
lcom 3
cbo 2
dl 0
loc 226
ccs 0
cts 53
cp 0
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
B exchangeArray() 0 9 7
A getArrayCopy() 0 4 1
A setInputFilter() 0 4 1
B getInputFilter() 0 130 2
A getUserService() 0 7 2
A setUserService() 0 5 1
A getServiceManager() 0 4 1
A setServiceManager() 0 5 1
A setServiceLocator() 0 4 1
A getServiceLocator() 0 4 1
1
<?php
2
/**
3
 * BB's Zend Framework 2 Components
4
 * 
5
 * AdminModule
6
 *
7
 * @package   [MyApplication]
8
 * @package   BB's Zend Framework 2 Components
9
 * @package   AdminModule
10
 * @author    Björn Bartels <[email protected]>
11
 * @link      https://gitlab.bjoernbartels.earth/groups/zf2
12
 * @license   http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
13
 * @copyright copyright (c) 2016 Björn Bartels <[email protected]>
14
 */
15
16
namespace Admin\Model;
17
18
use Zend\Crypt\Password\Bcrypt;
19
use Zend\InputFilter\InputFilter;
20
use Zend\InputFilter\Factory as InputFactory;
21
use Zend\InputFilter\InputFilterAwareInterface;
22
use Zend\InputFilter\InputFilterInterface;
23
use Zend\ServiceManager\ServiceLocatorInterface;
24
use Zend\ServiceManager\ServiceLocatorAwareInterface;
25
26
class Settings implements InputFilterAwareInterface, ServiceLocatorAwareInterface
27
{
28
    public $settings_id;
29
    public $scope;
30
    public $ref_id;
31
    public $type;
32
    public $name;
33
    public $value;
34
35
    protected $inputFilter;
36
    protected $userService;
37
    protected $serviceManager;
38
    protected $serviceLocator;
39
    
40
    public function exchangeArray($data)
41
    {
42
        $this->settings_id    = (isset($data['settings_id'])) ? $data['settings_id'] : null;
43
        $this->scope        = (isset($data['scope'])) ? $data['scope'] : null;
44
        $this->ref_id        = (isset($data['ref_id'])) ? $data['ref_id'] : null;
45
        $this->type            = (isset($data['type'])) ? $data['type'] : null;
46
        $this->name            = (isset($data['name'])) ? $data['name'] : null;
47
        $this->value        = (isset($data['value'])) ? $data['value'] : null;
48
    }
49
50
    public function getArrayCopy()
51
    {
52
        return get_object_vars($this);
53
    }
54
    
55
    public function setInputFilter(InputFilterInterface $inputFilter)
56
    {
57
        throw new \Exception("Not used");
58
    }
59
60
    public function getInputFilter()
61
    {
62
        if (!$this->inputFilter) {
63
            $inputFilter = new InputFilter();
64
            $factory     = new InputFactory();
65
66
            $inputFilter->add(
67
                $factory->createInput(
68
                    array(
69
                    'name'     => 'settings_id',
70
                    'required' => true,
71
                    'filters'  => array(
72
                    array('name' => 'Int'),
73
                    ),
74
                    )
75
                )
76
            );
77
78
            $inputFilter->add(
79
                $factory->createInput(
80
                    array(
81
                    'name'     => 'scope',
82
                    'required' => true,
83
                    'filters'  => array(
84
                    array('name' => 'StripTags'),
85
                    array('name' => 'StringTrim'),
86
                    ),
87
                    'validators' => array(
88
                    array(
89
                    'name'    => 'StringLength',
90
                    'options' => array(
91
                            'encoding' => 'UTF-8',
92
                            'min'      => 1,
93
                            'max'      => 32,
94
                    ),
95
                    ),
96
                    ),
97
                    )
98
                )
99
            );
100
101
            $inputFilter->add(
102
                $factory->createInput(
103
                    array(
104
                    'name'     => 'ref_id',
105
                    'required' => true,
106
                    'filters'  => array(
107
                    array('name' => 'StripTags'),
108
                    array('name' => 'StringTrim'),
109
                    ),
110
                    'validators' => array(
111
                    array(
112
                    'name'    => 'StringLength',
113
                    'options' => array(
114
                            'encoding' => 'UTF-8',
115
                            'min'      => 1,
116
                            'max'      => 32,
117
                    ),
118
                    ),
119
                    ),
120
                    )
121
                )
122
            );
123
124
            $inputFilter->add(
125
                $factory->createInput(
126
                    array(
127
                    'name'     => 'type',
128
                    'required' => true,
129
                    'filters'  => array(
130
                    array('name' => 'StripTags'),
131
                    array('name' => 'StringTrim'),
132
                    ),
133
                    'validators' => array(
134
                    array(
135
                    'name'    => 'StringLength',
136
                    'options' => array(
137
                            'encoding' => 'UTF-8',
138
                            'min'      => 1,
139
                            'max'      => 32,
140
                    ),
141
                    ),
142
                    ),
143
                    )
144
                )
145
            );
146
147
            $inputFilter->add(
148
                $factory->createInput(
149
                    array(
150
                    'name'     => 'name',
151
                    'required' => true,
152
                    'filters'  => array(
153
                    array('name' => 'StripTags'),
154
                    array('name' => 'StringTrim'),
155
                    ),
156
                    'validators' => array(
157
                    array(
158
                    'name'    => 'StringLength',
159
                    'options' => array(
160
                            'encoding' => 'UTF-8',
161
                            'min'      => 1,
162
                            'max'      => 32,
163
                    ),
164
                    ),
165
                    ),
166
                    )
167
                )
168
            );
169
170
            $inputFilter->add(
171
                $factory->createInput(
172
                    array(
173
                    'name'     => 'value',
174
                    'required' => false,
175
                    'filters'  => array(
176
                    array('name' => 'StripTags'),
177
                    array('name' => 'StringTrim'),
178
                    ),
179
                    'validators' => array(
180
                    ),
181
                    )
182
                )
183
            );
184
185
            $this->inputFilter = $inputFilter;
186
        }
187
188
        return $this->inputFilter;
189
    }
190
    /**
191
     * Getters/setters for DI stuff
192
     */
193
194
    public function getUserService()
195
    {
196
        if (!$this->userService) {
197
            $this->userService = $this->getServiceManager()->get('zfcuser_user_service');
198
        }
199
        return $this->userService;
200
    }
201
202
    public function setUserService(UserService $userService)
203
    {
204
        $this->userService = $userService;
205
        return $this;
206
    }
207
208
    /**
209
     * Retrieve service manager instance
210
     *
211
     * @return ServiceManager 
212
     */
213
    public function getServiceManager()
214
    {
215
        return $this->serviceManager;
216
    }
217
218
    /**
219
     * Set service manager instance
220
     *
221
     * @param  ServiceManager $serviceManager
222
     * @return User
223
     */
224
    public function setServiceManager(ServiceManager $serviceManager)
225
    {
226
        $this->serviceManager = $serviceManager;
227
        return $this;
228
    }
229
230
    /**
231
     * Set serviceManager instance
232
     *
233
     * @param  ServiceLocatorInterface $serviceLocator
234
     * @return void
235
     */
236
    public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
237
    {
238
        $this->serviceLocator = $serviceLocator;
239
    }
240
241
    /**
242
     * Retrieve serviceManager instance
243
     *
244
     * @return ServiceLocatorInterface
245
     */
246
    public function getServiceLocator()
247
    {
248
        return $this->serviceLocator;
249
    }
250
251
}