ReferenceException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 8
loc 8
rs 10
c 0
b 0
f 0
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
}