Completed
Push — master ( 2fcfdc...9f7c01 )
by De Cramer
11s
created

PlayerException::getTranslationParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace eXpansion\Framework\Core\Exceptions;
4
5
use Throwable;
6
7
/**
8
 * Class PlayerException, is a special type of extension that needs to be used only to display an error message to a
9
 * player. These exceptions should not be logged but always catched.
10
 *
11
 * @author    de Cramer Oliver<[email protected]>
12
 * @copyright 2017 eXpansion
13
 * @package eXpansion\Framework\Core\Exceptions
14
 */
15
class PlayerException extends ApplicationException
16
{
17
    /** @var string|null */
18
    protected $translatableMessage = null;
19
20
    /** @var string[] */
21
    protected $translationParameters;
22
23
    /**
24
     * PlayerException constructor.
25
     *
26
     * @param string $message
27
     * @param int $code
28
     * @param Throwable|null $previous
29
     * @param null $translatableMessage
30
     * @param string[] $translationParameters
31
     */
32 2
    public function __construct(
33
        $message = "",
34
        $code = 0,
35
        Throwable $previous = null,
36
        $translatableMessage = null,
37
        $translationParameters = []
38
    ) {
39 2
        parent::__construct($message, $code, $previous);
40
41 2
        $this->translatableMessage = $translatableMessage;
42 2
        $this->translationParameters = $translationParameters;
43 2
    }
44
45
    /**
46
     * Get error message to translate and send to users.
47
     *
48
     * @return string
49
     */
50 1
    public function getTranslatableMessage()
51
    {
52 1
        return is_null($this->translatableMessage) ? $this->message : $this->translatableMessage;
53
    }
54
55
    /**
56
     * Get paramters
57
     *
58
     * @return string[]
59
     */
60
    public function getTranslationParameters(): array
61
    {
62
        return $this->translationParameters;
63
    }
64
65
66
}