Completed
Push — develop ( f11aab...a4697b )
by Alejandro
09:31
created

MailServiceAwareTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 5
c 2
b 1
f 1
lcom 1
cbo 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMailService() 0 11 4
A setMailService() 0 6 1
1
<?php
2
namespace AcMailer\Service;
3
4
use Zend\ServiceManager\ServiceLocatorAwareInterface;
5
6
/**
7
 * Class MailServiceAwareTrait
8
 * @author Alejandro Celaya Alastrué
9
 * @link http://www.alejandrocelaya.com
10
 */
11
trait MailServiceAwareTrait
12
{
13
    /**
14
     * @var MailServiceInterface
15
     */
16
    protected $mailService;
17
18
    /**
19
     * @param MailServiceInterface $mailService
20
     * @return $this
21
     */
22
    public function setMailService(MailServiceInterface $mailService)
23
    {
24
        $this->mailService = $mailService;
25
26
        return $this;
27
    }
28
29
    /**
30
     * @return MailServiceInterface
31
     */
32
    public function getMailService()
33
    {
34
        if ($this instanceof ServiceLocatorAwareInterface
0 ignored issues
show
Bug introduced by
The class Zend\ServiceManager\ServiceLocatorAwareInterface does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
35
            && ! isset($this->mailService)
36
            && $this->getServiceLocator()->has('AcMailer\Service\MailService')
37
        ) {
38
            $this->mailService = $this->getServiceLocator()->get('AcMailer\Service\MailService');
39
        }
40
41
        return $this->mailService;
42
    }
43
}
44