Completed
Pull Request — master (#317)
by Guilherme
04:03
created

PhoneVerificationOptions::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 8
dl 0
loc 18
ccs 9
cts 9
cp 1
crap 1
rs 10
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\PhoneVerificationBundle\Service;
12
13
class PhoneVerificationOptions
14
{
15
    /** @var bool */
16
    private $caseSensitive;
17
18
    /** @var bool */
19
    private $useLowerCase;
20
21
    /** @var bool */
22
    private $useUpperCase;
23
24
    /** @var bool */
25
    private $useNumbers;
26
27
    /** @var int */
28
    private $length;
29
30
    /** @var string */
31
    private $smsResendTimeout;
32
33
    /** @var string */
34
    private $verificationTokenLength;
35
36
    /** @var int */
37
    private $enforceVerificationThreshold;
38
39
    /**
40
     * PhoneVerificationOptions constructor.
41
     * @param int $length
42
     * @param bool $useNumbers
43
     * @param bool $caseSensitive
44
     * @param bool $useLowerCase
45
     * @param bool $useUpperCase
46
     * @param $smsResendTimeout
47
     * @param $verificationTokenLength
48
     * @param int $enforceVerificationThreshold
49
     */
50 3
    public function __construct(
51
        $length,
52
        $useNumbers,
53
        $caseSensitive,
54
        $useLowerCase,
55
        $useUpperCase,
56
        $smsResendTimeout,
57
        $verificationTokenLength,
58
        int $enforceVerificationThreshold
59
    ) {
60 3
        $this->length = $length;
61 3
        $this->useNumbers = $useNumbers;
62 3
        $this->caseSensitive = $caseSensitive;
63 3
        $this->useLowerCase = $useLowerCase;
64 3
        $this->useUpperCase = $useUpperCase;
65 3
        $this->smsResendTimeout = $smsResendTimeout;
66 3
        $this->verificationTokenLength = $verificationTokenLength;
67 3
        $this->enforceVerificationThreshold = $enforceVerificationThreshold;
68 3
    }
69
70
    /**
71
     * @return bool
72
     */
73 1
    public function isCaseSensitive()
74
    {
75 1
        return $this->caseSensitive;
76
    }
77
78
    /**
79
     * @return bool
80
     */
81 1
    public function isUseLowerCase()
82
    {
83 1
        return $this->useLowerCase;
84
    }
85
86
    /**
87
     * @return bool
88
     */
89 1
    public function isUseUpperCase()
90
    {
91 1
        return $this->useUpperCase;
92
    }
93
94
    /**
95
     * @return bool
96
     */
97 1
    public function isUseNumbers()
98
    {
99 1
        return $this->useNumbers;
100
    }
101
102
    /**
103
     * @return int
104
     */
105 1
    public function getLength()
106
    {
107 1
        return $this->length;
108
    }
109
110 1
    public function getSmsResendTimeout()
111
    {
112 1
        return $this->smsResendTimeout;
113
    }
114
115
    /**
116
     * @return mixed
117
     */
118 1
    public function getVerificationTokenLength()
119
    {
120 1
        return $this->verificationTokenLength;
121
    }
122
123 3
    public function getEnforceVerificationThreshold(): int
124
    {
125 3
        return $this->enforceVerificationThreshold;
126
    }
127
}
128