Completed
Push — master ( 00f21d...76f138 )
by Boy
19:52 queued 16:05
created

GatewayApiSmsService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A sendSms() 0 13 1
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\GatewayBundle\Service;
20
21
use Surfnet\StepupBundle\Command\SendSmsCommand;
22
use Surfnet\StepupBundle\Service\SmsService;
23
use Surfnet\StepupGateway\ApiBundle\Dto\Requester;
24
use Surfnet\StepupGateway\ApiBundle\Dto\SmsMessage;
25
use Surfnet\StepupGateway\ApiBundle\Service\SmsService as ApiSmsService;
26
27
/**
28
 * Sends SMSes by calling the SMS service in the API bundle.
29
 */
30
final class GatewayApiSmsService implements SmsService
31
{
32
    /**
33
     * @var \Surfnet\StepupGateway\ApiBundle\Service\SmsService
34
     */
35
    private $smsService;
36
37
    public function __construct(ApiSmsService $smsService)
38
    {
39
        $this->smsService = $smsService;
40
    }
41
42
    /**
43
     * @param SendSmsCommand $command
44
     * @return bool
45
     */
46
    public function sendSms(SendSmsCommand $command)
47
    {
48
        $message = new SmsMessage();
49
        $message->recipient = $command->recipient;
50
        $message->originator = $command->originator;
51
        $message->body = $command->body;
52
53
        $requester = new Requester();
54
        $requester->identity = $command->identity;
55
        $requester->institution = $command->institution;
56
57
        return $this->smsService->send($message, $requester)->isSuccess();
58
    }
59
}
60