OrBlock   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 56
loc 56
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 1
A getPrimary() 4 4 1
A getSecondary() 4 4 1
A getProperties() 4 4 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 declare(strict_types=1);
2
3
namespace Limoncello\Validation\Blocks;
4
5
/**
6
 * Copyright 2015-2020 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
use Limoncello\Validation\Contracts\Blocks\ExecutionBlockInterface;
22
use Limoncello\Validation\Contracts\Blocks\OrExpressionInterface;
23
24
/**
25
 * @package Limoncello\Validation
26
 */
27 View Code Duplication
final class OrBlock implements OrExpressionInterface
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...
28
{
29
    /**
30
     * @var ExecutionBlockInterface
31
     */
32
    private $primary;
33
34
    /**
35
     * @var ExecutionBlockInterface
36
     */
37
    private $secondary;
38
39
    /**
40
     * @var array
41
     */
42
    private $properties;
43
44
    /**
45
     * @param ExecutionBlockInterface $primary
46
     * @param ExecutionBlockInterface $secondary
47
     * @param array                   $properties
48
     */
49 6
    public function __construct(
50
        ExecutionBlockInterface $primary,
51
        ExecutionBlockInterface $secondary,
52
        array $properties = []
53
    ) {
54 6
        $this->primary    = $primary;
55 6
        $this->secondary  = $secondary;
56 6
        $this->properties = $properties;
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62 5
    public function getPrimary(): ExecutionBlockInterface
63
    {
64 5
        return $this->primary;
65
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70 5
    public function getSecondary(): ExecutionBlockInterface
71
    {
72 5
        return $this->secondary;
73
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78 6
    public function getProperties(): array
79
    {
80 6
        return $this->properties;
81
    }
82
}
83