Issues (59)

src/Builder/MailerBuilder.php (1 issue)

1
<?php
2
3
namespace Da\Mailer\Builder;
4
5
use Da\Mailer\Mailer;
6
use Da\Mailer\Transport\TransportFactory;
7
use Exception;
8
9
class MailerBuilder extends Buildable
10
{
11
    /**
12
     * @param string|null $broker
13
     * @return Mailer
14
     * @throws Exception
15
     */
16
    public static function make($broker = null)
17
    {
18
        $config = self::getConfig();
19
20
        $transportType = $broker ?? $config['config']['transport'];
21
        $connectionValues = $config['transports'][$transportType];
22
        $transport = TransportFactory::create($connectionValues, $transportType)->create();
23
24
        return new Mailer($transport);
0 ignored issues
show
Bug Best Practice introduced by
The expression return new Da\Mailer\Mailer($transport) returns the type Da\Mailer\Mailer which is incompatible with the return type mandated by Da\Mailer\Builder\Buildable::make() of void.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
25
    }
26
}
27