Notify::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
eloc 11
c 2
b 0
f 0
nc 4
nop 16
dl 0
loc 21
rs 9.9

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, $email_subject,
7
                                $html, $text, $push_provider, $api_key, $user_key, $push_subject, $content, $url,
8
                                $priority)
9
    {
10
        if ($method == 'all') {
11
12
            $mail = new Mail();
13
            $mail->send($name, $address, $reply_name, $reply_address, $recipients, $email_subject, $html, $text);
14
15
            $push = new Push($push_provider);
16
            $push->push($api_key, $user_key, $push_subject, $content, $url, $priority);
17
18
        } elseif ($method == 'email') {
19
20
            $mail = new Mail();
21
            $mail->send($name, $address, $reply_name, $reply_address, $recipients, $email_subject, $html, $text);
22
23
        } elseif ($method == 'push') {
24
25
            $push = new Push($push_provider);
26
            $push->push($api_key, $user_key, $push_subject, $content, $url, $priority);
27
28
        }
29
    }
30
}
31