MailerBuilder   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 9 1
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