Decrypt   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 63.64 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 14
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A doRun() 14 14 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
 * @author Threema GmbH
4
 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
 */
6
7
8
namespace Threema\Console\Command;
9
10
use Threema\Console\Common;
11
use Threema\MsgApi\Tools\CryptTool;
12
13
class Decrypt extends Base {
14
	public function __construct() {
15
		parent::__construct('Decrypt',
16
			array(self::argPrivateKey, self::argPublicKey, self::argNonce),
17
			'Decrypt standard input using the given recipient private key and sender public key. The nonce must be given on the command line, and the box (hex) on standard input. Prints the decrypted message to standard output.');
18
	}
19
20 View Code Duplication
	protected function doRun() {
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...
21
		$cryptTool = CryptTool::getInstance();
22
23
		$privateKey = $this->getArgumentPrivateKey(self::argPrivateKey);
24
		$publicKey = $this->getArgumentPublicKey(self::argPublicKey);
25
		$nonce = $cryptTool->hex2bin($this->getArgument(self::argNonce));
26
		$input = $cryptTool->hex2bin($this->readStdIn());
27
28
		Common::required($privateKey, $publicKey, $nonce, $input);
29
		$cryptTool = CryptTool::getInstance();
30
		$message = $cryptTool->decryptMessage($input, $privateKey, $publicKey, $nonce);
31
32
		Common::l((String)$message);
33
	}
34
}
35