Failed Conditions
Branch ignore-unknown-keywords (efa676)
by Stéphane
02:58
created

NotConstraintTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 31.03 %

Coupling/Cohesion

Components 1
Dependencies 5
Metric Value
wmc 4
lcom 1
cbo 5
dl 9
loc 29
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testNormalizeThrowsIfNotIsNotObject() 0 6 1
A testNormalizeEnsuresNotIsAValidSchema() 9 9 1
A getConstraint() 0 4 1
A getCaseFileNames() 0 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
2
3
/*
4
 * This file is part of the JVal package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace JVal\Constraint;
11
12
use JVal\Context;
13
use JVal\Testing\ConstraintTestCase;
14
15
class NotConstraintTest extends ConstraintTestCase
16
{
17
    public function testNormalizeThrowsIfNotIsNotObject()
18
    {
19
        $this->expectConstraintException('InvalidTypeException', '/not');
20
        $schema = $this->loadSchema('invalid/not-not-object');
21
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
22
    }
23
24 View Code Duplication
    public function testNormalizeEnsuresNotIsAValidSchema()
0 ignored issues
show
Duplication introduced by
This method 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...
25
    {
26
        $schema = $this->loadSchema('valid/not-schema');
27
        $walker = $this->mockWalker();
28
        $walker->expects($this->at(0))
29
            ->method('parseSchema')
30
            ->with($schema->not);
31
        $this->getConstraint()->normalize($schema, new Context(), $walker);
32
    }
33
34
    protected function getConstraint()
35
    {
36
        return new NotConstraint();
37
    }
38
39
    protected function getCaseFileNames()
40
    {
41
        return ['not'];
42
    }
43
}
44