Completed
Push — master ( bd22e5...ae5621 )
by Julito
12:43
created

CalendarEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 10
dl 0
loc 23
rs 9.0856
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
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CourseBundle\Component\CourseCopy\Resources;
5
6
/**
7
 * Event backup script.
8
 *
9
 * @author Bart Mollet <[email protected]>
10
 *
11
 * @package chamilo.backup
12
 */
13
class CalendarEvent extends Resource
14
{
15
    /**
16
     * The title.
17
     */
18
    public $title;
19
    /**
20
     * The content.
21
     */
22
    public $content;
23
    /**
24
     * The start date.
25
     */
26
    public $start_date;
27
    /**
28
     * The end date.
29
     */
30
    public $end_date;
31
    /**
32
     * The attachment path.
33
     */
34
    public $attachment_path;
35
36
    /**
37
     * The attachment filename.
38
     */
39
    public $attachment_filename;
40
    /**
41
     * The attachment size.
42
     */
43
    public $attachment_size;
44
45
    /**
46
     * The attachment comment.
47
     */
48
    public $attachment_comment;
49
50
    /**
51
     * Create a new Event.
52
     *
53
     * @param int    $id
54
     * @param string $title
55
     * @param string $content
56
     */
57
    public function __construct(
58
        $id,
59
        $title,
60
        $content,
61
        $start_date,
62
        $end_date,
63
        $attachment_path = null,
64
        $attachment_filename = null,
65
        $attachment_size = null,
66
        $attachment_comment = null,
67
        $all_day = 0
68
    ) {
69
        parent::__construct($id, RESOURCE_EVENT);
70
71
        $this->title = $title;
72
        $this->content = $content;
73
        $this->start_date = $start_date;
74
        $this->end_date = $end_date;
75
        $this->all_day = $all_day;
0 ignored issues
show
Bug Best Practice introduced by
The property all_day does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
76
        $this->attachment_path = $attachment_path;
77
        $this->attachment_filename = $attachment_filename;
78
        $this->attachment_size = $attachment_size;
79
        $this->attachment_comment = $attachment_comment;
80
    }
81
82
    /**
83
     * Show this Event.
84
     */
85
    public function show()
86
    {
87
        parent::show();
88
        echo $this->title.' ('.$this->start_date.' -> '.$this->end_date.')';
89
    }
90
}
91