SwiftMessageTrait::getSwiftMessage()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 20

Duplication

Lines 20
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 0
Metric Value
dl 20
loc 20
ccs 10
cts 10
cp 1
rs 9.6
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4
1
<?php
2
3
namespace WShafer\PSR11MonoLog\Handler;
4
5
use WShafer\PSR11MonoLog\Exception\MissingConfigException;
6
use WShafer\PSR11MonoLog\Exception\MissingServiceException;
7
use WShafer\PSR11MonoLog\ServiceTrait;
8
9
trait SwiftMessageTrait
10
{
11
    use ServiceTrait;
12
13
    /**
14
     * @param $options
15
     * @return callable|\Swift_Message
16
     */
17 6 View Code Duplication
    public function getSwiftMessage($options)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    {
19 6
        if (empty($options['message'])) {
20 1
            throw new MissingConfigException(
21 1
                'No message service name or callback provided'
22
            );
23
        }
24
25 5
        if (is_callable($options['message'])) {
26 1
            return $options['message'];
27
        }
28
29 4
        if (!$this->getContainer()->has($options['message'])) {
30 1
            throw new MissingServiceException(
31 1
                'No Message service found'
32
            );
33
        }
34
35 3
        return $this->getContainer()->get($options['message']);
36
    }
37
}
38