Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Lines | 20 |
Ratio | 100 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
17 | 6 | View Code Duplication | public function getSwiftMessage($options) |
|
|||
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 |
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.