TopicCriteria   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 54
rs 10
c 3
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A filterWiki() 0 4 1
A filterVote() 0 4 1
A filterNobody() 0 4 1
A filterJobs() 0 4 1
A filterExcellent() 0 4 1
1
<?php
2
3
/**
4
 * Created by PhpStorm.
5
 * User: xuan
6
 * Date: 9/22/15
7
 * Time: 8:07 AM.
8
 */
9
10
namespace PHPHub\Repositories\Criteria;
11
12
class TopicCriteria extends BaseCriteria
13
{
14
    use OrderByCreatedTimeTrait;
15
16
    /**
17
     * 精华帖子.
18
     *
19
     * @param $model
20
     */
21
    public function filterExcellent($model)
22
    {
23
        return $model->where('is_excellent', 'yes');
24
    }
25
26
    /**
27
     * Wiki 帖子.
28
     *
29
     * @param $model
30
     */
31
    public function filterWiki($model)
32
    {
33
        return $model->where('is_wiki', 'yes');
34
    }
35
36
    /**
37
     * 按照投票数倒序排序.
38
     *
39
     * @param $model
40
     */
41
    public function filterVote($model)
42
    {
43
        return $model->orderBy('vote_count', 'desc');
44
    }
45
46
    /**
47
     * 无人回复的帖子.
48
     *
49
     * @param $model
50
     */
51
    public function filterNobody($model)
52
    {
53
        return $model->where('reply_count', 0);
54
    }
55
56
    /**
57
     * 招聘节点下的帖子.
58
     *
59
     * @param $model
60
     */
61
    public function filterJobs($model)
62
    {
63
        return $model->where('category_id', 1);
64
    }
65
}
66