FieldComponent   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 11 2
A __construct() 0 3 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
namespace LIN3S\WPFoundation\PostTypes\Fields\Components;
13
14
/**
15
 * Abstract class of base custom fields components.
16
 * This class enforces that all the field components need to
17
 * construct by register method.
18
 *
19
 * @author Beñat Espiña <[email protected]>
20
 * @author Gorka Laucirica <[email protected]>
21
 */
22
abstract class FieldComponent
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public static function register($aName, $aConnector)
28
    {
29
        if (method_exists(static::class, 'definition')) {
30
            $definition = static::definition($aName);
0 ignored issues
show
Bug introduced by
The method definition() does not seem to exist on object<LIN3S\WPFoundatio...ponents\FieldComponent>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
            $definition['location'] = $aConnector;
32
            acf_add_local_field_group($definition);
33
        } else {
34
            //@deprecated Will be removed in 2.0, and this class will implement FieldComponentInterface
35
            return new static($aName, $aConnector);
0 ignored issues
show
Unused Code introduced by
The call to FieldComponent::__construct() has too many arguments starting with $aName.

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...
36
        }
37
    }
38
39
    /**
40
     * Constructor.
41
     *
42
     * @deprecated since version 1.4, will be removed in 2.0. Implement register() instead
43
     */
44
    protected function __construct()
45
    {
46
    }
47
}
48