Completed
Pull Request — master (#194)
by De Cramer
24:15 queued 02:45
created

PlayerException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 29
rs 10
c 1
b 1
f 0
ccs 4
cts 6
cp 0.6667

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getTranslatableMessage() 0 4 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
    /**
21
     * PlayerException constructor.
22
     *
23
     * @param string $message
24
     * @param int $code
25
     * @param Throwable|null $previous
26
     * @param null $translatableMessage
27
     */
28 3
    public function __construct($message = "", $code = 0, Throwable $previous = null, $translatableMessage = null)
29
    {
30 3
        parent::__construct($message, $code, $previous);
31 3
        $this->translatableMessage = $translatableMessage;
32 3
    }
33
34
    /**
35
     * Get error message to translate and send to users.
36
     *
37
     * @return string
38
     */
39
    public function getTranslatableMessage()
40
    {
41
        return is_null($this->translatableMessage) ? $this->message : $this->translatableMessage;
42
    }
43
}