Broadcast   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 78
ccs 27
cts 27
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setLogger() 0 4 1
B triggerCampaign() 0 37 3
1
<?php
2
3
/**
4
 * This file is part of the Mediapart Selligent Client API
5
 *
6
 * CC BY-NC-SA <https://github.com/mediapart/selligent>
7
 *
8
 * For the full license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mediapart\Selligent;
13
14
use Psr\Log\LogLevel;
15
use Psr\Log\LoggerInterface;
16
use Psr\Log\LoggerAwareInterface;
17
use Mediapart\Selligent\Broadcast\Campaign;
18
use Mediapart\Selligent\Request\CreateCampaign;
19
20
/**
21
 *
22
 */
23
class Broadcast implements LoggerAwareInterface
24
{
25
    /**
26
     * @var \XMLWriter
27
     */
28
    protected $writer;
29
30
    /**
31
     * @var \SoapClient
32
     */
33
    protected $client;
34
35
    /**
36
     * @var LoggerInterface
37
     */
38
    protected $logger = null;
39
40
    /**
41
     * @param \SoapClient $client
42
     * @param string $list
0 ignored issues
show
Bug introduced by
There is no parameter named $list. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
43
     * @param string $campaign
0 ignored issues
show
Bug introduced by
There is no parameter named $campaign. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
44
     */
45 3
    public function __construct(\SoapClient $client)
46
    {
47 3
        $this->writer = new \XMLWriter();
48 3
        $this->client = $client;
49 3
    }
50
51
    /**
52
     * {@inheritDoc}
53
     */
54 2
    public function setLogger(LoggerInterface $logger)
55
    {
56 2
        $this->logger = $logger;
57 2
    }
58
59
    /**
60
     * @param Campaign $campaign
61
     * @return CreateCampaignResponse
62
     */
63 3
    public function triggerCampaign(Campaign $campaign)
64
    {
65 3
        $request = new CreateCampaign($this->writer);
66 3
        $response = $this->client->CreateCampaign([
67 3
            'Xml' => $request->basedOn($campaign)
68
        ]);
69
70 3
        if ($this->logger) {
71
72 2
            if (Response::SUCCESSFUL !== $response->getCode()) {
73 1
                $level = LogLevel::ERROR;
74 1
                $message = 'triggerCampaign has failed';
75
            } else {
76 1
                $level = LogLevel::INFO;
77 1
                $message = 'triggerCampaign with success';
78
            }
79
80 2
            $this->logger->log(
81 2
                $level,
82 2
                $message,
83
                [
84
                    'campaign' => [
85 2
                        'name' => $campaign->getName(),
86 2
                        'status' => $campaign->getStatus(),
0 ignored issues
show
Bug introduced by
The method getStatus() does not seem to exist on object<Mediapart\Selligent\Broadcast\Campaign>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
87 2
                        'stdate' => $campaign->getStartDate()->format(\DateTime::RFC850),
88
                    ],
89
                    'response' => [
90 2
                        'code' => $response->getCode(),
91 2
                        'error' => $response->getError(),
92 2
                        'result' => $response->getXml(),
93
                    ],
94
                ]
95
            );
96
        }
97
98 3
        return $response;
99
    }
100
}
101