LookupEmail   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 3 3 1
A getEmailAddress() 3 3 1
A getParams() 3 3 1
A getPath() 3 3 1
A parseResult() 3 3 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\MsgApi\Commands;
9
10
use Threema\MsgApi\Commands\CommandInterface;
11
use Threema\MsgApi\Commands\Results\LookupIdResult;
12
use Threema\MsgApi\Tools\CryptTool;
13
14 View Code Duplication
class LookupEmail implements CommandInterface {
0 ignored issues
show
Duplication introduced by
This class 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...
15
	/**
16
	 * @var string
17
	 */
18
	private $emailAddress;
19
20
	/**
21
	 * @param string $emailAddress
22
	 */
23
	public function __construct($emailAddress) {
24
		$this->emailAddress = $emailAddress;
25
	}
26
27
	/**
28
	 * @return string
29
	 */
30
	public function getEmailAddress() {
31
		return $this->emailAddress;
32
	}
33
34
	/**
35
	 * @return array
36
	 */
37
	public function getParams() {
38
		return array();
39
	}
40
41
	/**
42
	 * @return string
43
	 */
44
	public function getPath() {
45
		return 'lookup/email_hash/'.urlencode(CryptTool::getInstance()->hashEmail($this->emailAddress));
46
	}
47
48
	/**
49
	 * @param int $httpCode
50
	 * @param object $res
51
	 * @return LookupIdResult
52
	 */
53
	public function parseResult($httpCode, $res){
54
		return new LookupIdResult($httpCode, $res);
55
	}
56
}
57