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

Taxonomy::initTaxonomy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
}