Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 |
||
6 | public function __construct($method, $name, $address, $reply_name, $reply_address, $recipients, $subject, $html, |
||
7 | $text, $push_provider, $api_key, $user_key, $content, $url) |
||
8 | { |
||
9 | if ($method == 'all') { |
||
10 | |||
11 | $mail = new Mail(); |
||
12 | $mail->send($name, $address, $reply_name, $reply_address, $recipients, $subject, $html, $text); |
||
13 | |||
14 | $push = new Push($push_provider); |
||
15 | $push->push($api_key, $user_key, $subject, $content, $url); |
||
16 | |||
17 | } elseif ($method == 'email') { |
||
18 | |||
19 | $mail = new Mail(); |
||
20 | $mail->send($name, $address, $reply_name, $reply_address, $recipients, $subject, $html, $text); |
||
21 | |||
22 | } elseif ($method == 'push') { |
||
23 | |||
24 | $push = new Push($push_provider); |
||
25 | $push->push($api_key, $user_key, $subject, $content, $url); |
||
26 | |||
30 |