Passed
Push — master ( 76fde7...d6d75c )
by Magnus
01:55
created

Tag   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 51.85 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 14
loc 27
ccs 0
cts 16
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A returnAllSpecificTag() 14 14 3
A returnAllTags() 0 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 2017-09-27
6
 * Time: 10:27
7
 */
8
9
namespace Radchasay\Tag;
10
11
use \Anax\DI\InjectionAwareInterface;
12
use \Anax\Di\InjectionAwareTrait;
13
use \Anax\Database\ActiveRecordModel;
14
15
class Tag extends ActiveRecordModel implements InjectionAwareInterface
16
{
17
    use InjectionAwareTrait;
18
19 View Code Duplication
    public function returnAllSpecificTag($tag)
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...
20
    {
21
        $sql = "SELECT * FROM VPost WHERE Category = ?";
22
        $res = $this->findAllSql($sql, $tag);
23
        $id = [];
24
        $newRes = [];
25
        foreach ($res as $r) {
26
            if (!in_array($r->postid, $id)) {
27
                array_push($id, $r->postid);
28
                array_push($newRes, $r);
29
            }
30
        }
31
        return $newRes;
32
    }
33
34
35
    public function returnAllTags()
36
    {
37
        $sql = "SELECT Category FROM PostCategory";
38
        $res = $this->findAllSql($sql);
39
        return $res;
40
    }
41
}
42