Issues (16)

Notifications/HasMessageBuilderTrait.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace ByTIC\Notifications\Notifications;
4
5
use ByTIC\Notifications\Messages\Builder\EmailBuilder;
6
7
/**
8
 * Trait HasMessageBuilderTrait
9
 * @package ByTIC\Notifications\Notifications
10
 */
11
trait HasMessageBuilderTrait
12
{
13
14
    /**
15
     * @param string $type
16
     * @return mixed
17
     */
18
    public function generateMessageBuilder($type = 'mail')
19
    {
20
        $class = $this->generateMessageBuilderClass();
0 ignored issues
show
Are you sure the assignment to $class is correct as $this->generateMessageBuilderClass() targeting ByTIC\Notifications\Noti...teMessageBuilderClass() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

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

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

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

Loading history...
21
        $builder = new $class();
22
        return $builder;
23
    }
24
25
    /**
26
     * @return string
27
     */
28
    public function generateMailBuilderClass()
29
    {
30
        return EmailBuilder::class;
31
    }
32
33
    /**
34
     * @param string $type
35
     * @return null
36
     */
37
    protected function generateMessageBuilderClass($type = 'mail')
38
    {
39
        $method = 'generate' . ucfirst($type) . 'BuilderClass';
40
        if (method_exists($this, $method)) {
41
            return $this->$method();
42
        }
43
        return null;
44
    }
45
}
46