Completed
Push — master ( 9de5ff...fc4463 )
by Beñat
03:57
created

CustomPostTypeFields   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 44.44 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 1
dl 12
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A connector() 12 12 1
A removeScreenAttributes() 0 5 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
/*
4
 * This file is part of the WPFoundation library.
5
 *
6
 * Copyright (c) 2015 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
namespace LIN3S\WPFoundation\PostTypes\Fields\Templates;
13
14
use LIN3S\WPFoundation\PostTypes\Fields\Fields;
15
16
/**
17
 * Abstract custom post type fields class that extends the fields basic
18
 * behaviour, implementing the "connector" and "removeScreenAttributes"
19
 * methods with the common use case.
20
 *
21
 * @author Beñat Espiña <[email protected]>
22
 */
23
abstract class CustomPostTypeFields extends Fields
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 View Code Duplication
    public function connector()
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...
29
    {
30
        return [
31
            [
32
                [
33
                    'param'    => 'post_type',
34
                    'operator' => '==',
35
                    'value'    => $this->name,
36
                ],
37
            ],
38
        ];
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function removeScreenAttributes()
45
    {
46
        remove_post_type_support('page', 'comments');
47
        remove_post_type_support('page', 'custom-fields');
48
    }
49
}
50