UnorderedPhaseNumberException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 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 UnorderedPhaseNumberException 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 int */
20
  private $previousPhaseNumber;
21
  /** @var int */
22
  private $nextPhaseNumber;
23
//</editor-fold desc="Fields">
24
25
//<editor-fold desc="Constructor">
26
  /**
27
   * UnorderedPhaseNumberException constructor.
28
   * @param int $previousPhaseNumber
29
   * @param int $nextPhaseNumber
30
   */
31
  public function __construct(int $previousPhaseNumber, int $nextPhaseNumber)
32
  {
33
    $this->previousPhaseNumber = $previousPhaseNumber;
34
    $this->nextPhaseNumber = $nextPhaseNumber;
35
36
    $message = "The previous phase with number $previousPhaseNumber has a higher phase number than the next phase ";
37
    $message .= "with number $nextPhaseNumber";
38
    parent::__construct($message, 409);
39
  }
40
//</editor-fold desc="Constructor">
41
42
//<editor-fold desc="Public Methods">
43
  /**
44
   * Gets a json representation of the exception
45
   * @return array
46
   */
47
  public function getJsonMessage()
48
  {
49
    return [
50
      'message' => "Unordered Phase Number Exception",
51
      'previousPhaseNumber' => $this->previousPhaseNumber,
52
      'nextPhaseNumber' => $this->nextPhaseNumber
53
    ];
54
  }
55
//</editor-fold desc="Public Methods">
56
}