Overview::returnLimitPosts()   B
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 23
rs 8.7972
cc 4
eloc 18
nc 4
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 2017-09-27
6
 * Time: 10:27
7
 */
8
9
namespace Radchasay\Overview;
10
11
use \Anax\DI\InjectionAwareInterface;
12
use \Anax\Di\InjectionAwareTrait;
13
use \Radchasay\User\User;
14
use \Radchasay\Comment\Post;
15
16
class Overview implements InjectionAwareInterface
17
{
18
    use InjectionAwareTrait;
19
20
    public function returnLimitUsers($db, $order, $number)
21
    {
22
        $user = new User();
23
        $user->setDb($db);
24
        $res = $user->findAllLimitOrderBy($order, $number);
25
        return $res;
26
    }
27
28
    public function returnLimitPosts($db)
29
    {
30
        $post = new Post();
31
        $post->setDb($db);
32
        $sql = "Call VPost(null, null, 'desc', null, null)";
33
        $res = $post->findAllSql($sql);
34
        $post->getNext();
35
        $id = [];
36
        $newRes = [];
37
        $limitPost = 0;
38
        foreach ($res as $r) {
39
            if ($limitPost == 5) {
40
                return $newRes;
41
            } else {
42
                if (!in_array($r->postid, $id)) {
43
                    array_push($id, $r->postid);
44
                    array_push($newRes, $r);
45
                    $limitPost++;
46
                }
47
            }
48
        }
49
        return $newRes;
50
    }
51
52 View Code Duplication
    public function returnAllTagsFromPost($db, $id)
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...
53
    {
54
        $post = new Post();
55
        $post->setDb($db);
56
        $sql = "Call VCategory(?)";
57
        $res = $post->findAllSql($sql, $id);
58
        $post->getNext();
59
        return $res;
60
    }
61
62
63 View Code Duplication
    public function returnPopularTags($db)
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...
64
    {
65
        $post = new Post();
66
        $post->setDb($db);
67
        $sql = "Call PopularTags()";
68
        $res = $post->findAllSql($sql);
69
        $post->getNext();
70
        return $res;
71
    }
72
}
73