Completed
Push — master ( 4bb011...4b99be )
by Guillaume
13:23
created

ApiManager::getSupport()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 8
nc 4
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
        return true;
33
    }
34
    /**
35
     * @return bool|mixed
36
     */
37
    public function getSupport()
38
    {
39
        if (empty($this->config)) {
40
            return false;
41
        }
42
43
        foreach ($this->apiService as $service) {
44
            $service->setConfig($this->config);
45
            if ($service instanceof ApiInterface && $service->getSupport()) {
46
                return $service;
47
            }
48
        }
49
        return false;
50
    }
51
    /**
52
     * @param ApiInterface $service
53
     *
54
     * @return $this
55
     */
56
    public function addApiService(ApiInterface $service)
57
    {
58
        $this->apiService[] = $service;
59
        return $this;
60
    }
61
    /**
62
     * @return array
63
     */
64
    public function getApiService()
65
    {
66
        return $this->apiService;
67
    }
68
69
}
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...
70