MailHookService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getHooksForService() 0 6 1
1
<?php
2
3
namespace Swm\Bundle\MailHookBundle\Service;
4
5
use Swm\Bundle\MailHookBundle\ApiService\ApiServiceInterface;
6
use Swm\Bundle\MailHookBundle\Model as ApiServiceModel;
7
use Swm\Bundle\MailHookBundle\Provider\ProviderInterface;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\RequestStack;
10
11
class MailHookService
12
{
13
    /**
14
     * @var Request
15
     */
16
    private $request;
17
18
    /**
19
     * @var ProviderInterface
20
     */
21
    private $apiServiceModelProvider;
22
23
    /**
24
     * @param  RequestStack      $requestStack
25
     * @param  ProviderInterface $apiServiceProvider
26
     */
27
    public function __construct(RequestStack $requestStack, ProviderInterface $apiServiceProvider)
28
    {
29
        $this->request            = $requestStack->getCurrentRequest();
30
        $this->apiServiceProvider = $apiServiceProvider;
0 ignored issues
show
Bug introduced by
The property apiServiceProvider does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
31
    }
32
33
    /**
34
     * @param  string $serviceName
35
     * @return array<HookInterface>
36
     */
37
    public function getHooksForService($serviceName)
38
    {
39
        $apiService = $this->apiServiceProvider->get($serviceName)->setRequest($this->request);
40
41
        return $apiService->bind();
42
    }
43
}
44