PropertyNotExistingException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 7
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: 1/3/18
7
 * Time: 12:43 PM
8
 */
9
10
namespace Tfboe\FmLib\Exceptions;
11
12
/**
13
 * Class MethodNotExistingException
14
 * @package Tfboe\FmLib\Exceptions
15
 */
16
class PropertyNotExistingException extends AbstractException
17
{
18
//<editor-fold desc="Fields">
19
  /** @var string */
20
  private $propertyName;
21
22
  /** @var string */
23
  private $className;
24
25
  /** @var string */
26
  private $accessorMethod;
27
//</editor-fold desc="Fields">
28
//<editor-fold desc="Constructor">
29
30
31
  /**
32
   * PropertyNotExistingException constructor.
33
   * @param string $className
34
   * @param string $propertyName
35
   * @param string $accessorMethod
36
   */
37
  public function __construct(string $className, string $propertyName, string $accessorMethod)
38
  {
39
    $this->className = $className;
40
    $this->propertyName = $propertyName;
41
    $this->accessorMethod = $accessorMethod;
42
    parent::__construct("An object of the class $className had no property $propertyName via $accessorMethod");
43
  }
44
//</editor-fold desc="Constructor">
45
46
//<editor-fold desc="Public Methods">
47
  /**
48
   * Gets a json representation of the exception
49
   * @return array
50
   */
51
  public function getJsonMessage()
52
  {
53
    return [
54
      'message' => "Missing property in object",
55
      'className' => $this->className,
56
      'propertyName' => $this->propertyName,
57
      'accessorMethod' => $this->accessorMethod
58
    ];
59
  }
60
//</editor-fold desc="Public Methods">
61
}