Completed
Pull Request — master (#14)
by Gorka
12:44 queued 10:15
created

Taxonomy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
name() 0 1 ?
associatedPostType() 0 1 ?
options() 0 1 ?
A __construct() 0 11 1
A permalink() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the WPFoundation library.
5
 *
6
 * Copyright (c) 2015-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace LIN3S\WPFoundation\PostTypes;
15
16
/**
17
 * @author Beñat Espiña <[email protected]>
18
 * @author Gorka Laucirica <[email protected]>
19
 */
20
abstract class Taxonomy
21
{
22
    abstract public function name() : string;
23
24
    abstract public function associatedPostType() : string;
25
26
    abstract public function options() : TaxonomyOptions;
27
28
    public function __construct()
29
    {
30
        add_action('init', function () {
0 ignored issues
show
Unused Code introduced by
The call to the function add_action() seems unnecessary as the function has no side-effects.
Loading history...
31
            register_taxonomy(
32
                [$this, 'name'],
33
                [$this, 'associatedPostType'],
34
                [$this, 'options']
35
            );
36
        });
37
        add_filter('term_link', [$this, 'permalink'], 1, 2);
0 ignored issues
show
Unused Code introduced by
The call to add_filter() has too many arguments starting with 1.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
Unused Code introduced by
The call to the function add_filter() seems unnecessary as the function has no side-effects.
Loading history...
38
    }
39
40
    public function permalink(string $url, string $term) : string
0 ignored issues
show
Unused Code introduced by
The parameter $term 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...
41
    {
42
        return $url;
43
    }
44
}
45