Passed
Push — v5.x ( 00e299...57c2ac )
by Thierry
11:16
created

MessageTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 5
c 1
b 0
f 0
dl 0
loc 63
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A warning() 0 3 1
A error() 0 3 1
A success() 0 3 1
A info() 0 3 1
1
<?php
2
3
/**
4
 * MessageTrait.php - Default methods for alert messages.
5
 *
6
 * @package jaxon-core
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-core" is not valid; consider "Jaxoncore" instead
Loading history...
7
 * @author Thierry Feuzeu <[email protected]>
8
 * @copyright 2024 Thierry Feuzeu <[email protected]>
9
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
10
 * @link https://github.com/jaxon-php/jaxon-core
11
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
12
13
namespace Jaxon\App\Dialog\Library;
14
15
trait MessageTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait MessageTrait
Loading history...
16
{
17
    /**
18
     * Print an alert message.
19
     *
20
     * @param string $sContent The text of the message
21
     * @param string $sTitle The title of the message
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 1 found
Loading history...
22
     * @param string $sType The type of the message
0 ignored issues
show
Coding Style introduced by
Expected 4 spaces after parameter name; 1 found
Loading history...
23
     *
24
     * @return void
25
     */
26
    abstract protected function alert(string $sContent, string $sTitle, string $sType);
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
27
28
    /**
29
     * Show a success message.
30
     *
31
     * @param string $sMessage    The text of the message
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
32
     * @param string $sTitle    The title of the message
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
33
     *
34
     * @return void
35
     */
36
    public function success(string $sMessage, string $sTitle = '')
37
    {
38
        return $this->alert($sMessage, $sTitle, 'success');
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->alert($sMessage, $sTitle, 'success') targeting Jaxon\App\Dialog\Library\MessageTrait::alert() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
39
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
40
41
    /**
42
     * Show an information message.
43
     *
44
     * @param string $sMessage    The text of the message
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
45
     * @param string $sTitle    The title of the message
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
46
     *
47
     * @return void
48
     */
49
    public function info(string $sMessage, string $sTitle = '')
50
    {
51
        return $this->alert($sMessage, $sTitle, 'info');
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->alert($sMessage, $sTitle, 'info') targeting Jaxon\App\Dialog\Library\MessageTrait::alert() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
52
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
53
54
    /**
55
     * Show a warning message.
56
     *
57
     * @param string $sMessage    The text of the message
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
58
     * @param string $sTitle    The title of the message
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
59
     *
60
     * @return void
61
     */
62
    public function warning(string $sMessage, string $sTitle = '')
63
    {
64
        return $this->alert($sMessage, $sTitle, 'warning');
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->alert($sMessage, $sTitle, 'warning') targeting Jaxon\App\Dialog\Library\MessageTrait::alert() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
65
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
66
67
    /**
68
     * Show an error message.
69
     *
70
     * @param string $sMessage    The text of the message
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
71
     * @param string $sTitle    The title of the message
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
72
     *
73
     * @return void
74
     */
75
    public function error(string $sMessage, string $sTitle = '')
76
    {
77
        return $this->alert($sMessage, $sTitle, 'error');
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->alert($sMessage, $sTitle, 'error') targeting Jaxon\App\Dialog\Library\MessageTrait::alert() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
78
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
79
}
80