Completed
Branch develop (2aa849)
by Steve
09:08
created

ConditionalLogic   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getBuilder() 4 4 1
A transformValue() 5 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
namespace StoutLogic\AcfBuilder\Transform;
4
5
use StoutLogic\AcfBuilder\ConditionalBuilder;
6
7
/**
8
 * Applies the ConditionalField Transform to the conditional_logic value
9
 * of each field, in the field group config.
10
 */
11 View Code Duplication
class ConditionalLogic extends RecursiveTransform
0 ignored issues
show
Duplication introduced by
This class 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...
12
{
13
    protected $keys = ['conditional_logic'];
14
15
    /**
16
     * @param \StoutLogic\AcfBuilder\FieldsBuilder $builder
17
     */
18
    public function __construct(\StoutLogic\AcfBuilder\FieldsBuilder $builder)
19
    {
20
        parent::__construct($builder);
21
    }
22
23
    /**
24
     * @return \StoutLogic\AcfBuilder\FieldsBuilder
25
     */
26
    public function getBuilder()
27
    {
28
        return parent::getBuilder();
29
    }
30
31
    /**
32
     * Replace field values of a ConditionalBuilder with the proper keys using
33
     * the ConditionalField Transform.
34
     *
35
     * @param  ConditionalBuilder $value
36
     * @return array Transformed config array
37
     */
38
    public function transformValue($value)
39
    {
40
        $conditionalFieldTransform = new ConditionalField($this->getBuilder());
41
        return $conditionalFieldTransform->transform($value->build());
42
    }
43
}
44