ReferenceException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 1
A getJsonMessage() 8 8 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
declare(strict_types=1);
3
/**
4
 * Created by PhpStorm.
5
 * User: benedikt
6
 * Date: 10/20/17
7
 * Time: 3:16 PM
8
 */
9
10
namespace Tfboe\FmLib\Exceptions;
11
12
/**
13
 * Class DuplicateException
14
 * @package Tfboe\FmLib\Exceptions
15
 */
16 View Code Duplication
class ReferenceException extends AbstractException
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...
17
{
18
//<editor-fold desc="Fields">
19
  /** @var mixed */
20
  private $referenceValue;
21
  /** @var string */
22
  private $referenceName;
23
//</editor-fold desc="Fields">
24
25
//<editor-fold desc="Constructor">
26
  /**
27
   * ReferenceException constructor.
28
   * @param $referenceValue
29
   * @param string $referenceName
30
   */
31
  public function __construct($referenceValue, string $referenceName)
32
  {
33
    $this->referenceName = $referenceName;
34
    $this->referenceValue = $referenceValue;
35
36
    $message = "The reference $referenceValue of $referenceName is not existing!";
37
    parent::__construct($message, 409);
38
  }
39
//</editor-fold desc="Constructor">
40
41
//<editor-fold desc="Public Methods">
42
  /**
43
   * Gets a json representation of the exception
44
   * @return array
45
   */
46
  public function getJsonMessage()
47
  {
48
    return [
49
      'message' => "Reference Exception",
50
      'referenceValue' => $this->referenceValue,
51
      'referenceName' => $this->referenceName
52
    ];
53
  }
54
//</editor-fold desc="Public Methods">
55
}