ApiManager::getApiService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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