ProfileData   F
last analyzed

Complexity

Total Complexity 65

Size/Duplication

Total Lines 753
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 128
dl 0
loc 753
rs 3.2
c 0
b 0
f 0
wmc 65

62 Methods

Rating   Name   Duplication   Size   Complexity  
A isEvl() 0 3 1
A isMgmCategories() 0 3 1
A setConfigBackup() 0 5 1
A isAccAdd() 0 3 1
A isMgmAccounts() 0 3 1
A isConfigEncryption() 0 3 1
A setAccAdd() 0 5 1
A isAccFiles() 0 3 1
A setAccPrivateGroup() 0 5 1
A isAccEdit() 0 3 1
A setAccView() 0 5 1
A setAccDelete() 0 5 1
A setConfigGeneral() 0 5 1
A setMgmCustomFields() 0 5 1
A __wakeup() 0 7 3
A setAccEdit() 0 5 1
A setAccViewHistory() 0 5 1
A setMgmCategories() 0 5 1
A setMgmCustomers() 0 5 1
A isConfigGeneral() 0 3 1
A setMgmApiTokens() 0 5 1
A setMgmTags() 0 5 1
A setMgmUsers() 0 5 1
A setAccGlobalSearch() 0 5 1
A isMgmPublicLinks() 0 3 1
A setMgmProfiles() 0 5 1
A isAccPermission() 0 3 1
A setMgmPublicLinks() 0 5 1
A setMgmAccounts() 0 5 1
A isMgmGroups() 0 3 1
A setAccPermission() 0 5 1
A setAccPrivate() 0 5 1
A isAccViewHistory() 0 3 1
A setMgmFiles() 0 5 1
A setAccFiles() 0 5 1
A isAccPrivateGroup() 0 3 1
A setAccViewPass() 0 5 1
A isAccGlobalSearch() 0 3 1
A setMgmGroups() 0 5 1
A reset() 0 7 2
A isAccViewPass() 0 3 1
A isAccView() 0 3 1
A isAccEditPass() 0 3 1
A setEvl() 0 5 1
A isMgmTags() 0 3 1
A isMgmFiles() 0 3 1
A isConfigImport() 0 3 1
A isAccPrivate() 0 3 1
A setConfigEncryption() 0 5 1
A isMgmCustomFields() 0 3 1
A isMgmUsers() 0 3 1
A isAccDelete() 0 3 1
A setConfigImport() 0 5 1
A isMgmProfiles() 0 3 1
A isAccPublicLinks() 0 3 1
A setAccPublicLinks() 0 5 1
A isConfigBackup() 0 3 1
A isMgmApiTokens() 0 3 1
A setAccEditPass() 0 5 1
A isMgmCustomers() 0 3 1
A setMgmItemsPreset() 0 5 1
A isMgmItemsPreset() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like ProfileData often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ProfileData, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * sysPass
4
 *
5
 * @author    nuxsmin
6
 * @link      https://syspass.org
7
 * @copyright 2012-2019, Rubén Domínguez nuxsmin@$syspass.org
8
 *
9
 * This file is part of sysPass.
10
 *
11
 * sysPass is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation, either version 3 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * sysPass is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 *  along with sysPass.  If not, see <http://www.gnu.org/licenses/>.
23
 */
24
25
namespace SP\DataModel;
26
27
defined('APP_ROOT') || die();
28
29
/**
30
 * Class ProfileData
31
 *
32
 * @package SP\DataModel
33
 */
34
class ProfileData
35
{
36
    /**
37
     * @var bool
38
     */
39
    protected $accView = false;
40
    /**
41
     * @var bool
42
     */
43
    protected $accViewPass = false;
44
    /**
45
     * @var bool
46
     */
47
    protected $accViewHistory = false;
48
    /**
49
     * @var bool
50
     */
51
    protected $accEdit = false;
52
    /**
53
     * @var bool
54
     */
55
    protected $accEditPass = false;
56
    /**
57
     * @var bool
58
     */
59
    protected $accAdd = false;
60
    /**
61
     * @var bool
62
     */
63
    protected $accDelete = false;
64
    /**
65
     * @var bool
66
     */
67
    protected $accFiles = false;
68
    /**
69
     * @var bool
70
     */
71
    protected $accPrivate = false;
72
    /**
73
     * @var bool
74
     */
75
    protected $accPrivateGroup = false;
76
    /**
77
     * @var bool
78
     */
79
    protected $accPermission = false;
80
    /**
81
     * @var bool
82
     */
83
    protected $accPublicLinks = false;
84
    /**
85
     * @var bool
86
     */
87
    protected $accGlobalSearch = false;
88
    /**
89
     * @var bool
90
     */
91
    protected $configGeneral = false;
92
    /**
93
     * @var bool
94
     */
95
    protected $configEncryption = false;
96
    /**
97
     * @var bool
98
     */
99
    protected $configBackup = false;
100
    /**
101
     * @var bool
102
     */
103
    protected $configImport = false;
104
    /**
105
     * @var bool
106
     */
107
    protected $mgmUsers = false;
108
    /**
109
     * @var bool
110
     */
111
    protected $mgmGroups = false;
112
    /**
113
     * @var bool
114
     */
115
    protected $mgmProfiles = false;
116
    /**
117
     * @var bool
118
     */
119
    protected $mgmCategories = false;
120
    /**
121
     * @var bool
122
     */
123
    protected $mgmCustomers = false;
124
    /**
125
     * @var bool
126
     */
127
    protected $mgmApiTokens = false;
128
    /**
129
     * @var bool
130
     */
131
    protected $mgmPublicLinks = false;
132
    /**
133
     * @var bool
134
     */
135
    protected $mgmAccounts = false;
136
    /**
137
     * @var bool
138
     */
139
    protected $mgmTags = false;
140
    /**
141
     * @var bool
142
     */
143
    protected $mgmFiles = false;
144
    /**
145
     * @var bool
146
     */
147
    protected $mgmItemsPreset = false;
148
    /**
149
     * @var bool
150
     */
151
    protected $evl = false;
152
    /**
153
     * @var bool
154
     */
155
    protected $mgmCustomFields = false;
156
157
    /**
158
     * @return boolean
159
     */
160
    public function isAccView()
161
    {
162
        return $this->accView;
163
    }
164
165
    /**
166
     * @param boolean $accView
167
     *
168
     * @return ProfileData
169
     */
170
    public function setAccView($accView)
171
    {
172
        $this->accView = $accView;
173
174
        return $this;
175
    }
176
177
    /**
178
     * @return boolean
179
     */
180
    public function isAccViewPass()
181
    {
182
        return $this->accViewPass;
183
    }
184
185
    /**
186
     * @param boolean $accViewPass
187
     *
188
     * @return ProfileData
189
     */
190
    public function setAccViewPass($accViewPass)
191
    {
192
        $this->accViewPass = $accViewPass;
193
194
        return $this;
195
    }
196
197
    /**
198
     * @return boolean
199
     */
200
    public function isAccViewHistory()
201
    {
202
        return $this->accViewHistory;
203
    }
204
205
    /**
206
     * @param boolean $accViewHistory
207
     *
208
     * @return ProfileData
209
     */
210
    public function setAccViewHistory($accViewHistory)
211
    {
212
        $this->accViewHistory = $accViewHistory;
213
214
        return $this;
215
    }
216
217
    /**
218
     * @return boolean
219
     */
220
    public function isAccEdit()
221
    {
222
        return $this->accEdit;
223
    }
224
225
    /**
226
     * @param boolean $accEdit
227
     *
228
     * @return ProfileData
229
     */
230
    public function setAccEdit($accEdit)
231
    {
232
        $this->accEdit = $accEdit;
233
234
        return $this;
235
    }
236
237
    /**
238
     * @return boolean
239
     */
240
    public function isAccEditPass()
241
    {
242
        return $this->accEditPass;
243
    }
244
245
    /**
246
     * @param boolean $accEditPass
247
     *
248
     * @return ProfileData
249
     */
250
    public function setAccEditPass($accEditPass)
251
    {
252
        $this->accEditPass = $accEditPass;
253
254
        return $this;
255
    }
256
257
    /**
258
     * @return boolean
259
     */
260
    public function isAccAdd()
261
    {
262
        return $this->accAdd;
263
    }
264
265
    /**
266
     * @param boolean $accAdd
267
     *
268
     * @return ProfileData
269
     */
270
    public function setAccAdd($accAdd)
271
    {
272
        $this->accAdd = $accAdd;
273
274
        return $this;
275
    }
276
277
    /**
278
     * @return boolean
279
     */
280
    public function isAccDelete()
281
    {
282
        return $this->accDelete;
283
    }
284
285
    /**
286
     * @param boolean $accDelete
287
     *
288
     * @return ProfileData
289
     */
290
    public function setAccDelete($accDelete)
291
    {
292
        $this->accDelete = $accDelete;
293
294
        return $this;
295
    }
296
297
    /**
298
     * @return boolean
299
     */
300
    public function isAccFiles()
301
    {
302
        return $this->accFiles;
303
    }
304
305
    /**
306
     * @param boolean $accFiles
307
     *
308
     * @return ProfileData
309
     */
310
    public function setAccFiles($accFiles)
311
    {
312
        $this->accFiles = $accFiles;
313
314
        return $this;
315
    }
316
317
    /**
318
     * @return boolean
319
     */
320
    public function isAccPublicLinks()
321
    {
322
        return $this->accPublicLinks;
323
    }
324
325
    /**
326
     * @param boolean $accPublicLinks
327
     *
328
     * @return ProfileData
329
     */
330
    public function setAccPublicLinks($accPublicLinks)
331
    {
332
        $this->accPublicLinks = $accPublicLinks;
333
334
        return $this;
335
    }
336
337
    /**
338
     * @return boolean
339
     */
340
    public function isConfigGeneral()
341
    {
342
        return $this->configGeneral;
343
    }
344
345
    /**
346
     * @param boolean $configGeneral
347
     *
348
     * @return ProfileData
349
     */
350
    public function setConfigGeneral($configGeneral)
351
    {
352
        $this->configGeneral = $configGeneral;
353
354
        return $this;
355
    }
356
357
    /**
358
     * @return boolean
359
     */
360
    public function isConfigEncryption()
361
    {
362
        return $this->configEncryption;
363
    }
364
365
    /**
366
     * @param boolean $configEncryption
367
     *
368
     * @return ProfileData
369
     */
370
    public function setConfigEncryption($configEncryption)
371
    {
372
        $this->configEncryption = $configEncryption;
373
374
        return $this;
375
    }
376
377
    /**
378
     * @return boolean
379
     */
380
    public function isConfigBackup()
381
    {
382
        return $this->configBackup;
383
    }
384
385
    /**
386
     * @param boolean $configBackup
387
     *
388
     * @return ProfileData
389
     */
390
    public function setConfigBackup($configBackup)
391
    {
392
        $this->configBackup = $configBackup;
393
394
        return $this;
395
    }
396
397
    /**
398
     * @return boolean
399
     */
400
    public function isConfigImport()
401
    {
402
        return $this->configImport;
403
    }
404
405
    /**
406
     * @param boolean $configImport
407
     *
408
     * @return ProfileData
409
     */
410
    public function setConfigImport($configImport)
411
    {
412
        $this->configImport = $configImport;
413
414
        return $this;
415
    }
416
417
    /**
418
     * @return boolean
419
     */
420
    public function isMgmUsers()
421
    {
422
        return $this->mgmUsers;
423
    }
424
425
    /**
426
     * @param boolean $mgmUsers
427
     *
428
     * @return ProfileData
429
     */
430
    public function setMgmUsers($mgmUsers)
431
    {
432
        $this->mgmUsers = $mgmUsers;
433
434
        return $this;
435
    }
436
437
    /**
438
     * @return boolean
439
     */
440
    public function isMgmGroups()
441
    {
442
        return $this->mgmGroups;
443
    }
444
445
    /**
446
     * @param boolean $mgmGroups
447
     *
448
     * @return ProfileData
449
     */
450
    public function setMgmGroups($mgmGroups)
451
    {
452
        $this->mgmGroups = $mgmGroups;
453
454
        return $this;
455
    }
456
457
    /**
458
     * @return boolean
459
     */
460
    public function isMgmProfiles()
461
    {
462
        return $this->mgmProfiles;
463
    }
464
465
    /**
466
     * @param boolean $mgmProfiles
467
     *
468
     * @return ProfileData
469
     */
470
    public function setMgmProfiles($mgmProfiles)
471
    {
472
        $this->mgmProfiles = $mgmProfiles;
473
474
        return $this;
475
    }
476
477
    /**
478
     * @return boolean
479
     */
480
    public function isMgmCategories()
481
    {
482
        return $this->mgmCategories;
483
    }
484
485
    /**
486
     * @param boolean $mgmCategories
487
     *
488
     * @return ProfileData
489
     */
490
    public function setMgmCategories($mgmCategories)
491
    {
492
        $this->mgmCategories = $mgmCategories;
493
494
        return $this;
495
    }
496
497
    /**
498
     * @return boolean
499
     */
500
    public function isMgmCustomers()
501
    {
502
        return $this->mgmCustomers;
503
    }
504
505
    /**
506
     * @param boolean $mgmCustomers
507
     *
508
     * @return ProfileData
509
     */
510
    public function setMgmCustomers($mgmCustomers)
511
    {
512
        $this->mgmCustomers = $mgmCustomers;
513
514
        return $this;
515
    }
516
517
    /**
518
     * @return boolean
519
     */
520
    public function isMgmApiTokens()
521
    {
522
        return $this->mgmApiTokens;
523
    }
524
525
    /**
526
     * @param boolean $mgmApiTokens
527
     *
528
     * @return ProfileData
529
     */
530
    public function setMgmApiTokens($mgmApiTokens)
531
    {
532
        $this->mgmApiTokens = $mgmApiTokens;
533
534
        return $this;
535
    }
536
537
    /**
538
     * @return boolean
539
     */
540
    public function isMgmPublicLinks()
541
    {
542
        return $this->mgmPublicLinks;
543
    }
544
545
    /**
546
     * @param boolean $mgmPublicLinks
547
     *
548
     * @return ProfileData
549
     */
550
    public function setMgmPublicLinks($mgmPublicLinks)
551
    {
552
        $this->mgmPublicLinks = $mgmPublicLinks;
553
554
        return $this;
555
    }
556
557
    /**
558
     * @return boolean
559
     */
560
    public function isEvl()
561
    {
562
        return $this->evl;
563
    }
564
565
    /**
566
     * @param boolean $evl
567
     *
568
     * @return ProfileData
569
     */
570
    public function setEvl($evl)
571
    {
572
        $this->evl = $evl;
573
574
        return $this;
575
    }
576
577
    /**
578
     * @return boolean
579
     */
580
    public function isMgmCustomFields()
581
    {
582
        return $this->mgmCustomFields;
583
    }
584
585
    /**
586
     * @param boolean $mgmCustomFields
587
     *
588
     * @return ProfileData
589
     */
590
    public function setMgmCustomFields($mgmCustomFields)
591
    {
592
        $this->mgmCustomFields = $mgmCustomFields;
593
594
        return $this;
595
    }
596
597
    /**
598
     * unserialize() checks for the presence of a function with the magic name __wakeup.
599
     * If present, this function can reconstruct any resources that the object may have.
600
     * The intended use of __wakeup is to reestablish any database connections that may have been lost during
601
     * serialization and perform other reinitialization tasks.
602
     *
603
     * @return void
604
     * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep
605
     */
606
    public function __wakeup()
607
    {
608
        // Para realizar la conversión de nombre de propiedades que empiezan por _
609
        foreach (get_object_vars($this) as $name => $value) {
610
            if ($name[0] === '_') {
611
                $newName = substr($name, 1);
612
                $this->$newName = $value;
613
            }
614
        }
615
    }
616
617
    /**
618
     * @return boolean
619
     */
620
    public function isAccPrivate()
621
    {
622
        return $this->accPrivate;
623
    }
624
625
    /**
626
     * @param boolean $accPrivate
627
     *
628
     * @return ProfileData
629
     */
630
    public function setAccPrivate($accPrivate)
631
    {
632
        $this->accPrivate = $accPrivate;
633
634
        return $this;
635
    }
636
637
    /**
638
     * @return boolean
639
     */
640
    public function isAccPermission()
641
    {
642
        return $this->accPermission;
643
    }
644
645
    /**
646
     * @param boolean $accPermission
647
     *
648
     * @return ProfileData
649
     */
650
    public function setAccPermission($accPermission)
651
    {
652
        $this->accPermission = $accPermission;
653
654
        return $this;
655
    }
656
657
    /**
658
     * @return boolean
659
     */
660
    public function isMgmAccounts()
661
    {
662
        return $this->mgmAccounts;
663
    }
664
665
    /**
666
     * @param boolean $mgmAccounts
667
     *
668
     * @return ProfileData
669
     */
670
    public function setMgmAccounts($mgmAccounts)
671
    {
672
        $this->mgmAccounts = $mgmAccounts;
673
674
        return $this;
675
    }
676
677
    /**
678
     * @return boolean
679
     */
680
    public function isMgmTags()
681
    {
682
        return $this->mgmTags;
683
    }
684
685
    /**
686
     * @param boolean $mgmTags
687
     *
688
     * @return ProfileData
689
     */
690
    public function setMgmTags($mgmTags)
691
    {
692
        $this->mgmTags = $mgmTags;
693
694
        return $this;
695
    }
696
697
    /**
698
     * @return boolean
699
     */
700
    public function isMgmFiles()
701
    {
702
        return $this->mgmFiles;
703
    }
704
705
    /**
706
     * @param boolean $mgmFiles
707
     *
708
     * @return ProfileData
709
     */
710
    public function setMgmFiles($mgmFiles)
711
    {
712
        $this->mgmFiles = $mgmFiles;
713
714
        return $this;
715
    }
716
717
    /**
718
     * @return boolean
719
     */
720
    public function isAccGlobalSearch()
721
    {
722
        return $this->accGlobalSearch;
723
    }
724
725
    /**
726
     * @param boolean $accGlobalSearch
727
     *
728
     * @return ProfileData
729
     */
730
    public function setAccGlobalSearch($accGlobalSearch)
731
    {
732
        $this->accGlobalSearch = $accGlobalSearch;
733
734
        return $this;
735
    }
736
737
    /**
738
     * @return bool
739
     */
740
    public function isAccPrivateGroup()
741
    {
742
        return $this->accPrivateGroup;
743
    }
744
745
    /**
746
     * @param bool $accPrivateGroup
747
     *
748
     * @return ProfileData
749
     */
750
    public function setAccPrivateGroup($accPrivateGroup)
751
    {
752
        $this->accPrivateGroup = $accPrivateGroup;
753
754
        return $this;
755
    }
756
757
    /**
758
     * @return $this
759
     */
760
    public function reset()
761
    {
762
        foreach ($this as $property => $value) {
763
            $this->{$property} = false;
764
        }
765
766
        return $this;
767
    }
768
769
    /**
770
     * @return bool
771
     */
772
    public function isMgmItemsPreset(): bool
773
    {
774
        return $this->mgmItemsPreset;
775
    }
776
777
    /**
778
     * @param bool $mgmItemsPreset
779
     *
780
     * @return ProfileData
781
     */
782
    public function setMgmItemsPreset(bool $mgmItemsPreset)
783
    {
784
        $this->mgmItemsPreset = $mgmItemsPreset;
785
786
        return $this;
787
    }
788
}