Indexed   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 35.29 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 6
loc 17
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1
ccs 0
cts 7
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 6 11 3

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
 * File was created 29.02.2016 16:39
4
 */
5
6
namespace PeekAndPoke\Component\Slumber\Annotation\Slumber\Store;
7
8
use Doctrine\Common\Annotations\Annotation;
9
use PeekAndPoke\Component\Slumber\Annotation\PropertyStorageIndexMarker;
10
use PeekAndPoke\Component\Slumber\Core\Validation\ValidationContext;
11
12
/**
13
 * @Annotation
14
 * @Annotation\Target("PROPERTY")
15
 *
16
 * @author Karsten J. Gerber <[email protected]>
17
 */
18
class Indexed extends AbstractIndexDefinition implements PropertyStorageIndexMarker
19
{
20
    /**
21
     * @inheritdoc
22
     */
23
    public function validate(ValidationContext $context)
24
    {
25
        $direction = $this->getDirection();
26
27 View Code Duplication
        if ($direction !== self::ASCENDING && $direction !== self::DESCENDING) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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
            throw $this->createValidationException(
29
                $context,
30
                'The index direction must be "ASC" or "DESC" but "' . $direction . '" was found.'
31
            );
32
        }
33
    }
34
}
35