Indexed::validate()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 11

Duplication

Lines 6
Ratio 54.55 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 6
loc 11
ccs 0
cts 7
cp 0
rs 9.9
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 12
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