Completed
Push — release-1.x ( 0efa6c...32f2bb )
by Boy
07:06 queued 03:32
created

SmsService::send()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 7
nc 2
nop 2
1
<?php
2
3
/**
4
 * Copyright 2014 SURFnet bv
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace Surfnet\StepupGateway\ApiBundle\Service;
20
21
use Psr\Log\LoggerInterface;
22
use Surfnet\MessageBirdApiClient\Messaging\Message;
23
use Surfnet\MessageBirdApiClient\Messaging\SendMessageResult;
24
use Surfnet\MessageBirdApiClientBundle\Service\MessagingService;
25
use Surfnet\StepupGateway\ApiBundle\Dto\Requester;
26
use Surfnet\StepupGateway\ApiBundle\Dto\SmsMessage;
27
28
class SmsService
29
{
30
    /**
31
     * @var MessagingService
32
     */
33
    private $messagingService;
34
35
    /**
36
     * @var LoggerInterface
37
     */
38
    private $logger;
39
40
    /**
41
     * @param MessagingService $messagingService
42
     * @param LoggerInterface $logger
43
     */
44
    public function __construct(MessagingService $messagingService, LoggerInterface $logger)
45
    {
46
        $this->messagingService = $messagingService;
47
        $this->logger = $logger;
48
    }
49
50
    /**
51
     * @param SmsMessage $message
52
     * @param Requester $requester
53
     * @return SendMessageResult
54
     */
55
    public function send(SmsMessage $message, Requester $requester)
0 ignored issues
show
Unused Code introduced by
The parameter $requester is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
56
    {
57
        $this->logger->notice('Sending OTP per SMS.');
58
59
        $message = new Message($message->originator, $message->recipient, $message->body);
60
        $result = $this->messagingService->send($message);
61
62
        if (!$result->isSuccess()) {
63
            $this->logger->warning('Sending OTP per SMS failed.');
64
        }
65
66
        return $result;
67
    }
68
}
69