ApiManager   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A envoyer() 0 11 3
B getSupport() 0 15 5
A addApiService() 0 6 1
A getApiService() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: DIEU
5
 * Date: 02/05/2017
6
 * Time: 00:20
7
 */
8
9
namespace Starkerxp\CampaignBundle\Api;
10
11
class ApiManager extends AbstractApi
12
{
13
    /**
14
     * @var array
15
     */
16
    private $apiService = [];
17
18
    /**
19
     * @param $destinataire
20
     * @param array $content
21
     * @param array $options
22
     * @return bool
23
     */
24
    public function envoyer($destinataire, array $content, array $options = [])
25
    {
26
        if (empty($content)) {
27
            return false;
28
        }
29
        if ($apiService = $this->getSupport()) {
30
            $apiService->envoyer($destinataire, $content, $options);
31
        }
32
33
        return true;
34
    }
35
36
    /**
37
     * @return bool|mixed
38
     */
39
    public function getSupport()
40
    {
41
        if (empty($this->config)) {
42
            return false;
43
        }
44
45
        foreach ($this->apiService as $service) {
46
            $service->setConfig($this->config);
47
            if ($service instanceof ApiInterface && $service->getSupport()) {
48
                return $service;
49
            }
50
        }
51
52
        return false;
53
    }
54
55
    /**
56
     * @param ApiInterface $service
57
     *
58
     * @return $this
59
     */
60
    public function addApiService(ApiInterface $service)
61
    {
62
        $this->apiService[] = $service;
63
64
        return $this;
65
    }
66
67
    /**
68
     * @return array
69
     */
70
    public function getApiService()
71
    {
72
        return $this->apiService;
73
    }
74
75
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
76