Completed
Pull Request — master (#97)
by Sam
04:21
created

CdnskeyTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 60 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 12
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testFactory() 12 12 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
declare(strict_types=1);
4
5
/*
6
 * This file is part of Badcow DNS Library.
7
 *
8
 * (c) Samuel Williams <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Badcow\DNS\Tests\Rdata;
15
16
use Badcow\DNS\Algorithms;
17
use Badcow\DNS\Rdata\CDNSKEY;
18
use Badcow\DNS\Rdata\Factory;
19
use PHPUnit\Framework\TestCase;
20
21
class CdnskeyTest extends TestCase
22
{
23
    /**
24
     * @var string
25
     */
26
    private static $publicKey = 'AQPSKmynfzW4kyBv015MUG2DeIQ3Cbl+BBZH4b/0PY1kxkmvHjcZc8nokfzj31GajIQKY+5CptLr3buXA10hWqTkF7H6RfoRqXQeogmMHfpftf6zMv1LyBUgia7za6ZEzOJBOztyvhjL742iU/TpPSEDhm2SNKLijfUppn1UaNvv4w==';
27
28 View Code Duplication
    public function testFactory(): void
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...
29
    {
30
        $cdnskey = Factory::CDNSKEY(256, Algorithms::RSASHA1, base64_decode(self::$publicKey));
31
        $output = '256 3 5 '.self::$publicKey;
32
33
        $this->assertInstanceOf(CDNSKEY::class, $cdnskey);
34
        $this->assertEquals(256, $cdnskey->getFlags());
35
        $this->assertEquals(5, $cdnskey->getAlgorithm());
36
        $this->assertEquals(base64_decode(self::$publicKey), $cdnskey->getPublicKey());
37
        $this->assertEquals(3, $cdnskey->getProtocol());
38
        $this->assertEquals($output, $cdnskey->toText());
39
    }
40
}
41