UnorderedPhaseNumberException::getJsonMessage()   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 0
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 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
}