Passed
Pull Request — master (#5)
by Petr
04:44 queued 02:20
created

YourMembershipResponseException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 31
loc 31
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getApiMethodName() 3 3 1
A __toString() 4 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
namespace P2A\YourMembership\Exceptions;
3
4
/**
5
 * This is an exception that is thrown when an error occurs with the API responses.
6
 */
7 View Code Duplication
class YourMembershipResponseException extends YourMembershipException
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...
8
{
9
	/**
10
	 * Api Method That is related to this exception
11
	 * @var string
12
	 */
13
	private $apiMethod;
14
15 3
	public function __construct(string $message, int $code = 0, string $apiMethod, \Exception $e = null)
16
	{
17 3
		$this->apiMethod = $apiMethod;
18 3
		parent::__construct($message, $code, $e);
19 3
	}
20
21
	/**
22
	 * Returns the APi Method Name
23
	 * @method getApiMethodName
24
	 * @author PA
25
	 * @date   2017-01-12
26
	 * @return string
27
	 */
28 1
	public function getApiMethodName() : string {
29 1
		return $this->apiMethod;
30
	}
31
32 1
	public function __toString()
33
	{
34 1
	   return __CLASS__ . ": [{$this->apiMethod}]: {$this->message}\n";
35
    }
36
37
}
38