Conditions | 10 |
Paths | 512 |
Total Lines | 52 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
63 | public function __construct(array $config, $reserved) |
||
64 | { |
||
65 | parent::__construct($config, $reserved); |
||
66 | |||
67 | // Retrieve the mandatory product token from the configuration |
||
68 | if (isset($config['productToken'])) { |
||
69 | $this->productToken = $config['productToken']; |
||
70 | } |
||
71 | |||
72 | // Retrieve the optional allowPush from the configuration |
||
73 | if (isset($config['allowPush'])) { |
||
74 | $this->allowPush = $config['allowPush']; |
||
75 | } |
||
76 | |||
77 | // Retrieve the optional app key from the configuration |
||
78 | if (isset($config['appKey'])) { |
||
79 | $this->appKey = $config['appKey']; |
||
80 | } |
||
81 | |||
82 | // Retrieve the optional originator from the configuration |
||
83 | if (isset($config['originator'])) { |
||
84 | $this->originator = $config['originator']; |
||
85 | } |
||
86 | |||
87 | // Retrieve the optional message from the configuration |
||
88 | if (isset($config['message'])) { |
||
89 | $this->message = $config['message']; |
||
90 | } |
||
91 | |||
92 | // Retrieve the optional code length from the configuration |
||
93 | if (isset($config['codeLength'])) { |
||
94 | $this->codeLength = $config['codeLength']; |
||
95 | } |
||
96 | |||
97 | // Retrieve the optional attribute name that holds the mobile phone number |
||
98 | if (isset($config['mobilePhoneAttribute'])) { |
||
99 | $this->mobilePhoneAttribute = $config['mobilePhoneAttribute']; |
||
100 | } |
||
101 | |||
102 | // Retrieve the optional validFor |
||
103 | if (isset($config['validFor'])) { |
||
104 | $this->validFor = $config['validFor']; |
||
105 | } |
||
106 | |||
107 | // Retrieve the optional defaultRegion |
||
108 | if (isset($config['defaultRegion'])) { |
||
109 | $this->defaultRegion = $config['defaultRegion']; |
||
110 | } |
||
111 | |||
112 | Assert::notEmpty( |
||
113 | $this->mobilePhoneAttribute, |
||
114 | 'mobilePhoneAttribute cannot be an empty string.', |
||
115 | ); |
||
187 |