Completed
Push — 1.10.x ( c0da86...0328a9 )
by
unknown
125:03 queued 74:59
created

Announcement::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 21
c 1
b 0
f 0
nc 1
nop 10
dl 0
loc 25
rs 8.8571

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
/* For licensing terms, see /license.txt */
3
4
require_once 'Resource.class.php';
5
6
/**
7
 * An announcement
8
 * @author Bart Mollet <[email protected]>
9
 * @package chamilo.backup
10
 */
11
class Announcement extends Coursecopy\Resource
12
{
13
    /**
14
     * The title of the announcement
15
     */
16
    public $title;
17
    /**
18
     * The content of the announcement
19
     */
20
    public $content;
21
    /**
22
     * The date on which this announcement was made
23
     */
24
    public $date;
25
    /**
26
     * The display order of this announcement
27
     */
28
    public $display_order;
29
    /**
30
     * Has the e-mail been sent?
31
     */
32
    public $email_sent;
33
34
    public $attachment_path;
35
36
    public $attachment_filename;
37
38
    public $attachment_size;
39
40
    public $attachment_comment;
41
42
    /**
43
     * Create a new announcement
44
     * @param int $id
45
     * @param string $title
46
     * @param string $content
47
     * @param string $date
48
     * @param int display_order
49
     */
50
    public function __construct(
51
        $id,
52
        $title,
53
        $content,
54
        $date,
55
        $display_order,
56
        $email_sent,
57
        $path,
58
        $filename,
59
        $size,
60
        $comment
61
    ) {
62
        parent::__construct($id,RESOURCE_ANNOUNCEMENT);
63
64
        $this->content	= $content;
65
        $this->title 	= $title;
66
        $this->date 	= $date;
67
        $this->display_order	= $display_order;
68
        $this->email_sent	 	= $email_sent;
69
70
        $this->attachment_path 	= $path;
71
        $this->attachment_filename = $filename;
72
        $this->attachment_size 	= $size;
73
        $this->attachment_comment 	= $comment;
74
    }
75
76
    /**
77
     * Show this announcement
78
     */
79
    function show()
80
    {
81
        parent::show();
82
        echo $this->date.': '.$this->title;
83
    }
84
}
85