Completed
Push — master ( 00e474...9d3fbd )
by Michael
04:26
created

Oledrion_shelf_parameters::setLimit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * oledrion
14
 *
15
 * @copyright   {@link http://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 */
19
/**
20
 * Classe interne dont le but est de passer des paramètres à la classe oeldrion_shelf
21
 */
22
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
23
24
/**
25
 * Utilisé comme paramètre dans la façcade oledrion_shelf
26
 */
27
class Oledrion_shelf_parameters
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
28
{
29
    /**
30
     * Le conteneur de paramètres
31
     *
32
     * @var array
33
     */
34
    private $parameters = array();
35
36
    /**
37
     * Oledrion_shelf_parameters constructor.
38
     */
39
    public function __construct()
40
    {
41
        $this->resetDefaultValues();
42
    }
43
44
    /**
45
     * Réinitialisation des valeurs
46
     *
47
     * @return object
48
     */
49
    public function resetDefaultValues()
50
    {
51
        $this->parameters['start']               = 0;
52
        $this->parameters['limit']               = 0;
53
        $this->parameters['category']            = 0;
54
        $this->parameters['sort']                = 'product_submitted DESC, product_title';
55
        $this->parameters['order']               = 'ASC';
56
        $this->parameters['excluded']            = 0;
57
        $this->parameters['withXoopsUser']       = false;
58
        $this->parameters['withRelatedProducts'] = false;
59
        $this->parameters['withQuantity']        = false;
60
        $this->parameters['thisMonthOnly']       = false;
61
        $this->parameters['productsType']        = '';
62
63
        return $this;
64
    }
65
66
    /**
67
     * Retourne le tableau des paramètres
68
     *
69
     * @return array
70
     */
71
    public function getParameters()
72
    {
73
        return $this->parameters;
74
    }
75
76
    /**
77
     * Positione la valeur de début
78
     *
79
     * @param  integer $value
80
     * @return object
81
     */
82
    public function setStart($value)
83
    {
84
        $this->parameters['start'] = (int)$value;
85
86
        return $this;
87
    }
88
89
    /**
90
     * Fixe le nombre maximum d'enregistrements à retourner
91
     *
92
     * @param  integer $value
93
     * @return object
94
     */
95
    public function setLimit($value)
96
    {
97
        $this->parameters['limit'] = (int)$value;
98
99
        return $this;
100
    }
101
102
    /**
103
     * Fixe la catégorie à utiliser
104
     *
105
     * @param  integer $value
106
     * @return object
107
     */
108
    public function setCategory($value)
109
    {
110
        $this->parameters['category'] = $value;
111
112
        return $this;
113
    }
114
115
    /**
116
     * Fixe la zone qui sert de tri
117
     *
118
     * @param  string $value
119
     * @return object
120
     */
121
    public function setSort($value)
122
    {
123
        $this->parameters['sort'] = $value;
124
125
        return $this;
126
    }
127
128
    /**
129
     * Fixe l'ordre de tri
130
     *
131
     * @param  string $value
132
     * @return array
0 ignored issues
show
Documentation introduced by
Should the return type not be Oledrion_shelf_parameters?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
133
     */
134
    public function setOrder($value)
135
    {
136
        $this->parameters['order'] = $value;
137
138
        return $this;
139
    }
140
141
    /**
142
     * Fixe la liste des produits à exclure
143
     *
144
     * @param  mixed $value
145
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be Oledrion_shelf_parameters?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
146
     */
147
    public function setExcluded($value)
148
    {
149
        $this->parameters['excluded'] = $value;
150
151
        return $this;
152
    }
153
154
    /**
155
     * Indique s'il faut retourner les utilisateurs Xoops
156
     *
157
     * @param  boolean $value
158
     * @return object
159
     */
160
    public function setWithXoopsUser($value)
161
    {
162
        $this->parameters['withXoopsUser'] = $value;
163
164
        return $this;
165
    }
166
167
    /**
168
     * Indique s'il faut retourner les produits relatifs
169
     *
170
     * @param  boolean $value
171
     * @return object
172
     */
173
    public function setWithRelatedProducts($value)
174
    {
175
        $this->parameters['withRelatedProducts'] = $value;
176
177
        return $this;
178
    }
179
180
    /**
181
     * Indique s'il faut retourner les quantités
182
     *
183
     * @param  boolean $value
184
     * @return object
185
     */
186
    public function setWithQuantity($value)
187
    {
188
        $this->parameters['withQuantity'] = $value;
189
190
        return $this;
191
    }
192
193
    /**
194
     * Fixe le type de produits à retourner
195
     *
196
     * @param  string $value
197
     * @return object
198
     */
199
    public function setProductsType($value)
200
    {
201
        $this->parameters['productsType'] = $value;
202
203
        return $this;
204
    }
205
206
    /**
207
     * Indique s'il faut retourner seulement les mois
208
     *
209
     * @param  boolean $value
210
     * @return object
211
     */
212
    public function setThisMonthOnly($value)
213
    {
214
        $this->parameters['thisMonthOnly'] = $value;
215
216
        return $this;
217
    }
218
}
219