Completed
Push — master ( d71805...ee9560 )
by Gorka
14s
created

Taxonomy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A initTaxonomy() 0 4 1
1
<?php
2
3
namespace LIN3S\WPFoundation\PostTypes;
4
5
final class Taxonomy
6
{
7
    private $taxonomy;
8
    private $postType;
9
    private $options;
10
11
    /**
12
     * Creates a taxonomy for the given post type
13
     *
14
     * @param string $taxonomy Taxonomy identifier
15
     * @param string $postType Post type identifier
16
     * @param array $options Array of options allowed in register_taxonomy method. See for more info
17
     * https://codex.wordpress.org/Function_Reference/register_taxonomy
18
     */
19
    public function __construct($taxonomy, $postType, $options)
20
    {
21
        $this->taxonomy = $taxonomy;
22
        $this->postType = $postType;
23
        $this->options = $options;
24
25
        add_action('init', [$this, 'initTaxonomy']);
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...
26
    }
27
28
    public function initTaxonomy()
29
    {
30
        register_taxonomy($this->taxonomy, $this->postType, $this->options);
31
    }
32
}