GameSubmission::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 46
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 23
nc 4
nop 17
dl 0
loc 46
rs 9.552
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 AL\Common\Model\GameSubmission;
3
4
require_once __DIR__."/../../../config/config.php";
5
require_once __DIR__."/../../../lib/functions.php";
6
7
/**
8
 * Maps to the `GameSubmission' table
9
 */
10
class GameSubmission {
11
    private $game_id;
12
    private $game_name;
13
    private $timestamp;
14
    private $date;
0 ignored issues
show
introduced by
The private property $date is not used, and could be removed.
Loading history...
15
    private $comment;
16
    private $submission_id;
17
    private $done;
18
    private $userid;
19
    private $username;
20
    private $email;
21
    private $join_date;
0 ignored issues
show
introduced by
The private property $join_date is not used, and could be removed.
Loading history...
22
    private $karma;
23
    private $show_email;
24
    private $avatar_ext;
0 ignored issues
show
introduced by
The private property $avatar_ext is not used, and could be removed.
Loading history...
25
    private $user_subm_count;
26
    private $user_comment_count;
27
    private $screenshots;
28
29
    public function __construct(
30
        $game_id,
31
        $game_name,
32
        $timestamp,
33
        $date,
34
        $comment,
35
        $submission_id,
36
        $done,
37
        $userid,
38
        $username,
39
        $email,
40
        $join_date,
41
        $karma,
42
        $show_email,
43
        $avatar_ext,
44
        $user_subm_count,
45
        $user_comment_count,
46
        $screenshots
47
    ) {
48
        $this->game_id = $game_id;
49
        $this->game_name = $game_name;
50
        $this->timestamp = $timestamp;
51
        $this->post_date = date("F j, Y", $date);
0 ignored issues
show
Bug Best Practice introduced by
The property post_date does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
52
        $this->comment = $comment;
53
        $this->submission_id = $submission_id;
54
        $this->done = $done;
55
        $this->userid = $userid;
56
        $this->username = $username;
57
        $this->email = $email;
58
        $this->screenshots = $screenshots;
59
60
        if ($join_date == "") {
61
            $this->join = "unknown";
0 ignored issues
show
Bug Best Practice introduced by
The property join does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
62
        } else {
63
            $this->join = date("d-m-y", $join_date);
64
        }
65
66
        $this->karma = $karma;
67
        $this->show_email = $show_email;
68
        $this->user_subm_count = $user_subm_count;
69
        $this->user_comment_count = $user_comment_count;
70
71
        if ($avatar_ext && $avatar_ext !== "") {
72
            $this->avatar_image = $GLOBALS['user_avatar_path']."/{$userid}.{$avatar_ext}";
0 ignored issues
show
Bug Best Practice introduced by
The property avatar_image does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
73
        } else {
74
            $this->avatar_image = $GLOBALS['style_folder']."/images/default_avatar_image.png";
75
        }
76
    }
77
78
    public function getGameId() {
79
        return $this->game_id;
80
    }
81
82
    public function getName() {
83
        return $this->game_name;
84
    }
85
86
    public function getComment() {
87
        return $this->comment;
88
    }
89
90
    public function getDate() {
91
        return $this->post_date;
92
    }
93
94
    public function getSubmissionId() {
95
        return $this->submission_id;
96
    }
97
98
    public function getDone() {
99
        return $this->done;
100
    }
101
102
    public function getUserId() {
103
        return $this->userid;
104
    }
105
106
    public function getUserName() {
107
        return $this->username;
108
    }
109
110
    public function getEmail() {
111
        return $this->email;
112
    }
113
114
    public function getJoinDate() {
115
        return $this->join;
116
    }
117
118
    public function getKarma() {
119
        return $this->karma;
120
    }
121
122
    public function getShowEmail() {
123
        return $this->show_email;
124
    }
125
126
    public function getAvatarImage() {
127
        return $this->avatar_image;
128
    }
129
130
    public function getUserSubCount() {
131
        return $this->user_subm_count;
132
    }
133
134
    public function getUserCommentCount() {
135
        return $this->user_comment_count;
136
    }
137
138
    public function getTimestamp() {
139
        return $this->timestamp;
140
    }
141
142
    public function getScreenshots() {
143
        return $this->screenshots;
144
    }
145
}
146