Link::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 2
nop 10
dl 0
loc 24
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 AL\Common\Model\Link;
3
4
require_once __DIR__."/../../../config/config.php";
5
6
/**
7
 * Maps to the `website` table
8
 */
9
class Link {
10
    private $id;
11
    private $name;
12
    private $url;
13
    private $description;
14
    private $image;
15
    private $inactive;
16
    private $user;
17
    private $date;
18
    private $userid;
19
    private $category_name;
20
21
    public function __construct(
22
        $id,
23
        $name,
24
        $url,
25
        $description,
26
        $imgext,
27
        $inactive,
28
        $user,
29
        $date,
30
        $userid,
31
        $category_name
32
    ) {
33
        $this->id = $id;
34
        $this->name = $name;
35
        $this->url = $url;
36
        $this->description = $description;
37
        $this->inactive = $inactive;
38
        $this->user = $user;
39
        $this->date = $date;
40
        $this->userid = $userid;
41
        $this->category_name = $category_name;
42
43
        if ($imgext && $imgext !== "") {
44
            $this->image = $GLOBALS['website_image_path']."/{$id}.{$imgext}";
45
        }
46
    }
47
48
    public function getName() {
49
        return $this->name;
50
    }
51
52
    public function getUrl() {
53
        return $this->url;
54
    }
55
56
    public function getDescription() {
57
        return $this->description;
58
    }
59
60
    public function getImage() {
61
        return $this->image;
62
    }
63
64
    public function getInactive() {
65
        return $this->inactive;
66
    }
67
68
    public function getUser() {
69
        return $this->user;
70
    }
71
72
    public function getUserId() {
73
        return $this->userid;
74
    }
75
76
    public function getDate() {
77
        return $this->date;
78
    }
79
80
    public function getCategoryName() {
81
        return $this->category_name;
82
    }
83
}
84