Completed
Push — master ( 5d89d9...b6c216 )
by Robbie
15s queued 10s
created

OpenSSLCryptoTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 31.25 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 5
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testIntegrity() 5 13 2

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
namespace SilverStripe\HybridSessions\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use SilverStripe\HybridSessions\Crypto\OpenSSLCrypto;
7
8
/**
9
 * @requires extension openssl
10
 */
11
class OpenSSLCryptoTest extends SapphireTest
12
{
13
    public function testIntegrity()
14
    {
15
        $key = random_bytes(8);
16
        $salt = random_bytes(16);
17
18
        $handler = new OpenSSLCrypto($key, $salt);
19
20 View Code Duplication
        for ($i = 0; $i < 1000; ++$i) {
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...
21
            $data = random_bytes(1024 * 4);
22
23
            $this->assertEquals($data, $handler->decrypt($handler->encrypt($data)));
24
        }
25
    }
26
}
27