Completed
Push — master ( c0739b...54ec6b )
by Alex
21s queued 14s
created

ODataFeed::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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

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
3
declare(strict_types=1);
4
5
namespace POData\ObjectModel;
6
7
/**
8
 * Class ODataFeed.
9
 */
10
class ODataFeed
11
{
12
    /**
13
     * Feed iD.
14
     *
15
     * @var string
16
     */
17
    public $id;
18
    /**
19
     * Feed title.
20
     *
21
     * @var ODataTitle
22
     */
23
    public $title;
24
    /**
25
     * Feed self link.
26
     *
27
     * @var ODataLink
28
     */
29
    public $selfLink;
30
    /**
31
     * Row count, in case of $inlinecount option.
32
     *
33
     * @var int
34
     */
35
    public $rowCount = null;
36
    /**
37
     * Enter URL to next page, if pagination is enabled.
38
     *
39
     * @var ODataLink
40
     */
41
    public $nextPageLink = null;
42
    /**
43
     * Collection of entries under this feed.
44
     *
45
     * @var ODataEntry[]
46
     */
47
    public $entries = [];
48
49
    /**
50
     * Last updated timestamp.
51
     *
52
     * @var string
53
     */
54
    public $updated;
55
56
    /**
57
     * Service Base URI.
58
     *
59
     * @var string
60
     */
61
    public $baseURI;
62
63
    /**
64
     * ODataFeed constructor.
65
     * @param string       $id
66
     * @param ODataTitle   $title
67
     * @param ODataLink    $selfLink
68
     * @param int          $rowCount
69
     * @param ODataLink    $nextPageLink
70
     * @param ODataEntry[] $entries
71
     * @param string       $updated
72
     * @param string       $baseURI
73
     */
74
    public function __construct(string $id = null, ODataTitle $title = null, ODataLink $selfLink = null, int $rowCount = null, ODataLink $nextPageLink = null, array $entries = [], string $updated = null, string $baseURI = null)
75
    {
76
        $this->id           = $id;
77
        $this->title        = $title;
78
        $this->selfLink     = $selfLink;
79
        $this->rowCount     = $rowCount;
80
        $this->nextPageLink = $nextPageLink;
81
        $this->entries      = $entries;
82
        $this->updated      = $updated;
83
        $this->baseURI      = $baseURI;
84
    }
85
86
    /**
87
     * @return ODataLink
88
     */
89
    public function getNextPageLink()
90
    {
91
        return $this->nextPageLink;
92
    }
93
94
    /**
95
     * @param ODataLink $nextPageLink
96
     */
97
    public function setNextPageLink(ODataLink $nextPageLink)
98
    {
99
        foreach (get_object_vars($nextPageLink) as $property) {
100
            if (null !== $property) {
101
                $this->nextPageLink = $nextPageLink;
102
                return;
103
            }
104
        }
105
    }
106
107
    /**
108
     * @return ODataEntry[]
109
     */
110
    public function getEntries()
111
    {
112
        return $this->entries;
113
    }
114
115
    /**
116
     * @param ODataEntry[] $entries
117
     */
118
    public function setEntries(array $entries)
119
    {
120
        $this->entries = $entries;
121
    }
122
}
123