Passed
Push — main ( cd5745...cfa081 )
by Sílvio
10:20 queued 07:29
created

ConnectionException::setBefore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Silviooosilva\CacheerPhp\Exceptions;
4
5
use Exception;
6
7
class ConnectionException extends BaseException
8
{
9
    private static string $before = "<Connection Exception>";
10
11
    /**
12
     * @param string $message
13
     * @param int $code
14
     * @param Exception|null $previous
15
     * @param array $details
16
     * @return self
17
     */
18
    public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = [])
19
    {
20
        return new self(self::getBefore() . ": " . $message, $code, $previous, $details);
21
    }
22
23
    /**
24
     * @return string
25
     */
26
    public static function getBefore(): string
27
    {
28
        return self::$before;
29
    }
30
31
    /**
32
     * @param string $text
33
     */
34
    public static function setBefore(string $text): void
35
    {
36
        self::$before = $text;
37
    }
38
39
    /*
40
    * @return array
41
    */
42
    public function toArray()
43
    {
44
        return parent::toArray();
45
    }
46
    
47
    /**
48
     * @return string
49
     */
50
    public function jsonSerialize(): array
51
    {
52
        return parent::jsonSerialize();
53
    }
54
55
    /**
56
     * @param int $options
57
     * @return string
58
     */
59
    public function toJson(int $options = 0)
60
    {
61
      return parent::toJson($options);
62
    }
63
}
64