Passed
Push — master ( c9ca19...a23bb5 )
by Greg
01:52
created

Notify::__construct()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
nc 4
nop 14
dl 0
loc 20
rs 9.9
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
namespace GJClasses;
3
4
class Notify
5
{
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
27
        }
28
    }
29
}
30