CacheDatabaseException::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Silviooosilva\CacheerPhp\Exceptions;
4
5
use Exception;
6
7
class CacheDatabaseException extends BaseException
8
{
9
10
  /** @param string $before */
11
  private static string $before = "<Database Cache Store Exception>";
12
13
  /**
14
   * Creates a new instance of CacheDatabaseException.
15
   * 
16
   * @param string $message
17
   * @param int $code
18
   * @param Exception|null $previous
19
   * @param array $details
20
   * @return self
21
   */
22
  public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = [])
23
  {
24
    return new self(self::getBefore() . ": " .$message, $code, $previous, $details);
25
  }
26
27
28
  /**
29
  * Gets the static text that will be prepended to the exception message.
30
  *
31
  * @return string
32
  */
33
  public static function getBefore(): string
34
  {
35
    return self::$before;
36
  }
37
38
  /**
39
  * Sets the static text that will be prepended to the exception message.
40
  *
41
  * @return void
42
  */
43
  public static function setBefore(string $text)
44
  {
45
    self::$before = $text;
46
  }
47
48
   /*
49
    * Converts the exception to an array representation.
50
    *
51
    * @return array
52
    */
53
    public function toArray()
54
    {
55
        return parent::toArray();
56
    }
57
    
58
    /**
59
     * Converts the exception to a JSON serializable format.
60
     *
61
     * @return string
62
     */
63
    public function jsonSerialize(): array
64
    {
65
        return parent::jsonSerialize();
66
    }
67
68
    /**
69
     * Converts the exception to a JSON string.
70
     * 
71
     * @param int $options
72
     * @return string
73
     */
74
    public function toJson(int $options = 0)
75
    {
76
      return parent::toJson($options);
77
    }
78
}
79