Completed
Branch master (caa4fc)
by Michael
06:53 queued 04:04
created

MyXoopsStory::store()   D

Complexity

Conditions 15
Paths 384

Size

Total Lines 57
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
cc 15
eloc 43
c 5
b 0
f 0
nc 384
nop 1
dl 0
loc 57
rs 4.8021

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 28 and the first side effect is on line 22.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * XOOPS news story
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright       XOOPS Project (http://xoops.org)
13
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @package         kernel
15
 * @since           2.0.0
16
 * @author          Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
17
 * @deprecated
18
 */
19
20
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% 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...
21
//$GLOBALS['xoopsLogger']->addDeprecated("'/class/xoopsstory.php' is deprecated since XOOPS 2.5.4, please create your own class instead.");
22
include_once XOOPS_ROOT_PATH . '/modules/news/class/xoopstopic.php';
23
include_once XOOPS_ROOT_PATH . '/kernel/user.php';
24
25
/**
26
 * Class MyXoopsStory
27
 */
28
class MyXoopsStory
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...
29
{
30
    public $table;
31
    public $storyid;
32
    public $topicid;
33
    public $uid;
34
    public $title;
35
    public $hometext;
36
    public $bodytext  = '';
37
    public $counter;
38
    public $created;
39
    public $published;
40
    public $expired;
41
    public $hostname;
42
    public $nohtml    = 0;
43
    public $nosmiley  = 0;
44
    public $ihome     = 0;
45
    public $notifypub = 0;
46
    public $type;
47
    public $approved;
48
    public $topicdisplay;
49
    public $topicalign;
50
    public $db;
51
    public $topicstable;
52
    public $comments;
53
54
    /**
55
     * @param $storyid
56
     */
57
    public function Story($storyid = -1)
58
    {
59
        $this->db          = XoopsDatabaseFactory::getDatabaseConnection();
60
        $this->table       = '';
61
        $this->topicstable = '';
62 View Code Duplication
        if (is_array($storyid)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
            $this->makeStory($storyid);
64
        } elseif ($storyid != -1) {
65
            $this->getStory((int)$storyid);
66
        }
67
    }
68
69
    /**
70
     * @param $value
71
     */
72
    public function setStoryId($value)
73
    {
74
        $this->storyid = (int)$value;
75
    }
76
77
    /**
78
     * @param $value
79
     */
80
    public function setTopicId($value)
81
    {
82
        $this->topicid = (int)$value;
83
    }
84
85
    /**
86
     * @param $value
87
     */
88
    public function setUid($value)
89
    {
90
        $this->uid = (int)$value;
91
    }
92
93
    /**
94
     * @param $value
95
     */
96
    public function setTitle($value)
97
    {
98
        $this->title = $value;
99
    }
100
101
    /**
102
     * @param $value
103
     */
104
    public function setHometext($value)
105
    {
106
        $this->hometext = $value;
107
    }
108
109
    /**
110
     * @param $value
111
     */
112
    public function setBodytext($value)
113
    {
114
        $this->bodytext = $value;
115
    }
116
117
    /**
118
     * @param $value
119
     */
120
    public function setPublished($value)
121
    {
122
        $this->published = (int)$value;
123
    }
124
125
    /**
126
     * @param $value
127
     */
128
    public function setExpired($value)
129
    {
130
        $this->expired = (int)$value;
131
    }
132
133
    /**
134
     * @param $value
135
     */
136
    public function setHostname($value)
137
    {
138
        $this->hostname = $value;
139
    }
140
141
    /**
142
     * @param int $value
143
     */
144
    public function setNohtml($value = 0)
145
    {
146
        $this->nohtml = $value;
147
    }
148
149
    /**
150
     * @param int $value
151
     */
152
    public function setNosmiley($value = 0)
153
    {
154
        $this->nosmiley = $value;
155
    }
156
157
    /**
158
     * @param $value
159
     */
160
    public function setIhome($value)
161
    {
162
        $this->ihome = $value;
163
    }
164
165
    /**
166
     * @param $value
167
     */
168
    public function setNotifyPub($value)
169
    {
170
        $this->notifypub = $value;
171
    }
172
173
    /**
174
     * @param $value
175
     */
176
    public function setType($value)
177
    {
178
        $this->type = $value;
179
    }
180
181
    /**
182
     * @param $value
183
     */
184
    public function setApproved($value)
185
    {
186
        $this->approved = (int)$value;
187
    }
188
189
    /**
190
     * @param $value
191
     */
192
    public function setTopicdisplay($value)
193
    {
194
        $this->topicdisplay = $value;
195
    }
196
197
    /**
198
     * @param $value
199
     */
200
    public function setTopicalign($value)
201
    {
202
        $this->topicalign = $value;
203
    }
204
205
    /**
206
     * @param $value
207
     */
208
    public function setComments($value)
209
    {
210
        $this->comments = (int)$value;
211
    }
212
213
    /**
214
     * @param bool $approved
215
     *
216
     * @return bool
217
     */
218
    public function store($approved = false)
0 ignored issues
show
Unused Code introduced by
The parameter $approved is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
219
    {
220
        //$newpost = 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
221
        $myts     = MyTextSanitizer::getInstance();
222
        $title    = $myts->censorString($this->title);
223
        $hometext = $myts->censorString($this->hometext);
224
        $bodytext = $myts->censorString($this->bodytext);
225
        $title    = $myts->addSlashes($title);
226
        $hometext = $myts->addSlashes($hometext);
227
        $bodytext = $myts->addSlashes($bodytext);
228
        if (!isset($this->nohtml) || $this->nohtml != 1) {
229
            $this->nohtml = 0;
230
        }
231
        if (!isset($this->nosmiley) || $this->nosmiley != 1) {
232
            $this->nosmiley = 0;
233
        }
234
        if (!isset($this->notifypub) || $this->notifypub != 1) {
235
            $this->notifypub = 0;
236
        }
237
        if (!isset($this->topicdisplay) || $this->topicdisplay != 0) {
238
            $this->topicdisplay = 1;
239
        }
240
        $expired = !empty($this->expired) ? $this->expired : 0;
241
        if (!isset($this->storyid)) {
242
            //$newpost = 1;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
243
            $newstoryid = $this->db->genId($this->table . '_storyid_seq');
244
            $created    = time();
245
            $published  = $this->approved ? $this->published : 0;
246
247
            $sql =
248
                sprintf("INSERT INTO %s (storyid, uid, title, created, published, expired, hostname, nohtml, nosmiley, hometext, bodytext, counter, topicid, ihome, notifypub, story_type, topicdisplay, topicalign, comments) VALUES (%u, %u, '%s', %u, %u, %u, '%s', %u, %u, '%s', '%s', %u, %u, %u, %u, '%s', %u, '%s', %u)",
249
                        $this->table, $newstoryid, $this->uid, $title, $created, $published, $expired, $this->hostname, $this->nohtml, $this->nosmiley, $hometext, $bodytext, 0, $this->topicid,
250
                        $this->ihome, $this->notifypub, $this->type, $this->topicdisplay, $this->topicalign, $this->comments);
251
        } else {
252
            if ($this->approved) {
253
                $sql =
254
                    sprintf("UPDATE %s SET title = '%s', published = %u, expired = %u, nohtml = %u, nosmiley = %u, hometext = '%s', bodytext = '%s', topicid = %u, ihome = %u, topicdisplay = %u, topicalign = '%s', comments = %u WHERE storyid = %u",
255
                            $this->table, $title, $this->published, $expired, $this->nohtml, $this->nosmiley, $hometext, $bodytext, $this->topicid, $this->ihome, $this->topicdisplay,
256
                            $this->topicalign, $this->comments, $this->storyid);
257
            } else {
258
                $sql =
259
                    sprintf("UPDATE %s SET title = '%s', expired = %u, nohtml = %u, nosmiley = %u, hometext = '%s', bodytext = '%s', topicid = %u, ihome = %u, topicdisplay = %u, topicalign = '%s', comments = %u WHERE storyid = %u",
260
                            $this->table, $title, $expired, $this->nohtml, $this->nosmiley, $hometext, $bodytext, $this->topicid, $this->ihome, $this->topicdisplay, $this->topicalign, $this->comments,
261
                            $this->storyid);
262
            }
263
            $newstoryid = $this->storyid;
264
        }
265
        if (!$result = $this->db->query($sql)) {
266
            return false;
267
        }
268
        if (empty($newstoryid)) {
269
            $newstoryid    = $this->db->getInsertId();
270
            $this->storyid = $newstoryid;
271
        }
272
273
        return $newstoryid;
274
    }
275
276
    /**
277
     * @param $storyid
278
     */
279 View Code Duplication
    public function getStory($storyid)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
280
    {
281
        $storyid = (int)$storyid;
282
        $sql     = 'SELECT * FROM ' . $this->table . ' WHERE storyid=' . $storyid . '';
283
        $array   = $this->db->fetchArray($this->db->query($sql));
284
        $this->makeStory($array);
285
    }
286
287
    /**
288
     * @param $array
289
     */
290
    public function makeStory($array)
291
    {
292
        foreach ($array as $key => $value) {
293
            $this->$key = $value;
294
        }
295
    }
296
297
    /**
298
     * @return bool
299
     */
300 View Code Duplication
    public function delete()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
301
    {
302
        $sql = sprintf('DELETE FROM %s WHERE storyid = %u', $this->table, $this->storyid);
303
        if (!$result = $this->db->query($sql)) {
304
            return false;
305
        }
306
307
        return true;
308
    }
309
310
    /**
311
     * @return bool
312
     */
313 View Code Duplication
    public function updateCounter()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
314
    {
315
        $sql = sprintf('UPDATE %s SET counter = counter+1 WHERE storyid = %u', $this->table, $this->storyid);
316
        if (!$result = $this->db->queryF($sql)) {
317
            return false;
318
        }
319
320
        return true;
321
    }
322
323
    /**
324
     * @param $total
325
     *
326
     * @return bool
327
     */
328 View Code Duplication
    public function updateComments($total)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
329
    {
330
        $sql = sprintf('UPDATE %s SET comments = %u WHERE storyid = %u', $this->table, $total, $this->storyid);
331
        if (!$result = $this->db->queryF($sql)) {
332
            return false;
333
        }
334
335
        return true;
336
    }
337
338
    public function topicid()
339
    {
340
        return $this->topicid;
341
    }
342
343
    /**
344
     * @return MyXoopsTopic
345
     */
346
    public function topic()
347
    {
348
        return new MyXoopsTopic($this->topicstable, $this->topicid);
349
    }
350
351
    public function uid()
352
    {
353
        return $this->uid;
354
    }
355
356
    /**
357
     * @return string
358
     */
359
    public function uname()
360
    {
361
        return XoopsUser::getUnameFromId($this->uid);
362
    }
363
364
    /**
365
     * @param string $format
366
     *
367
     * @return mixed
368
     */
369 View Code Duplication
    public function title($format = 'Show')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
370
    {
371
        $myts   = MyTextSanitizer::getInstance();
372
        $smiley = 1;
0 ignored issues
show
Unused Code introduced by
$smiley is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
373
        if ($this->nosmiley()) {
374
            $smiley = 0;
0 ignored issues
show
Unused Code introduced by
$smiley is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
375
        }
376
        switch ($format) {
377
            case 'Show':
378
            case 'Edit':
379
                $title = $myts->htmlSpecialChars($this->title);
380
                break;
381
            case 'Preview':
382
            case 'InForm':
383
                $title = $myts->htmlSpecialChars($myts->stripSlashesGPC($this->title));
384
                break;
385
        }
386
387
        return $title;
0 ignored issues
show
Bug introduced by
The variable $title does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
388
    }
389
390
    /**
391
     * @param string $format
392
     *
393
     * @return string
394
     */
395 View Code Duplication
    public function hometext($format = 'Show')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
396
    {
397
        $myts   = MyTextSanitizer::getInstance();
398
        $html   = 1;
399
        $smiley = 1;
400
        $xcodes = 1;
401
        if ($this->nohtml()) {
402
            $html = 0;
403
        }
404
        if ($this->nosmiley()) {
405
            $smiley = 0;
406
        }
407
        switch ($format) {
408
            case 'Show':
409
                $hometext = $myts->displayTarea($this->hometext, $html, $smiley, $xcodes);
410
                break;
411
            case 'Edit':
412
                $hometext = htmlspecialchars($this->hometext, ENT_QUOTES);
413
                break;
414
            case 'Preview':
415
                $hometext = $myts->previewTarea($this->hometext, $html, $smiley, $xcodes);
416
                break;
417
            case 'InForm':
418
                $hometext = htmlspecialchars($myts->stripSlashesGPC($this->hometext), ENT_QUOTES);
419
                break;
420
        }
421
422
        return $hometext;
0 ignored issues
show
Bug introduced by
The variable $hometext does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
423
    }
424
425
    /**
426
     * @param string $format
427
     *
428
     * @return string
429
     */
430 View Code Duplication
    public function bodytext($format = 'Show')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
431
    {
432
        $myts   = MyTextSanitizer::getInstance();
433
        $html   = 1;
434
        $smiley = 1;
435
        $xcodes = 1;
436
        if ($this->nohtml()) {
437
            $html = 0;
438
        }
439
        if ($this->nosmiley()) {
440
            $smiley = 0;
441
        }
442
        switch ($format) {
443
            case 'Show':
444
                $bodytext = $myts->displayTarea($this->bodytext, $html, $smiley, $xcodes);
445
                break;
446
            case 'Edit':
447
                $bodytext = htmlspecialchars($this->bodytext, ENT_QUOTES);
448
                break;
449
            case 'Preview':
450
                $bodytext = $myts->previewTarea($this->bodytext, $html, $smiley, $xcodes);
451
                break;
452
            case 'InForm':
453
                $bodytext = htmlspecialchars($myts->stripSlashesGPC($this->bodytext), ENT_QUOTES);
454
                break;
455
        }
456
457
        return $bodytext;
0 ignored issues
show
Bug introduced by
The variable $bodytext does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
458
    }
459
460
    public function counter()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
461
    {
462
        return $this->counter;
463
    }
464
465
    public function created()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
466
    {
467
        return $this->created;
468
    }
469
470
    public function published()
471
    {
472
        return $this->published;
473
    }
474
475
    public function expired()
476
    {
477
        return $this->expired;
478
    }
479
480
    public function hostname()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
481
    {
482
        return $this->hostname;
483
    }
484
485
    public function storyid()
486
    {
487
        return $this->storyid;
488
    }
489
490
    /**
491
     * @return int
492
     */
493
    public function nohtml()
494
    {
495
        return $this->nohtml;
496
    }
497
498
    /**
499
     * @return int
500
     */
501
    public function nosmiley()
502
    {
503
        return $this->nosmiley;
504
    }
505
506
    /**
507
     * @return int
508
     */
509
    public function notifypub()
510
    {
511
        return $this->notifypub;
512
    }
513
514
    public function type()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
515
    {
516
        return $this->type;
517
    }
518
519
    /**
520
     * @return int
521
     */
522
    public function ihome()
523
    {
524
        return $this->ihome;
525
    }
526
527
    public function topicdisplay()
528
    {
529
        return $this->topicdisplay;
530
    }
531
532
    /**
533
     * @param bool $astext
534
     *
535
     * @return string
536
     */
537
    public function topicalign($astext = true)
538
    {
539
        if ($astext) {
540
            if ($this->topicalign === 'R') {
541
                $ret = 'right';
542
            } else {
543
                $ret = 'left';
544
            }
545
546
            return $ret;
547
        }
548
549
        return $this->topicalign;
550
    }
551
552
    public function comments()
553
    {
554
        return $this->comments;
555
    }
556
}
557