Completed
Push — master ( 41e5ad...f2b4de )
by Alexandre
02:39
created

Twilio   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A notifyOwner() 0 12 2
1
<?php
2
3
namespace AppBundle\Service;
4
5
use Psr\Log\LoggerInterface;
6
7
class Twilio
8
{
9
    private $logger;
10
    private $client;
11
    private $twilioFrom;
12
    private $twilioTo;
13
14
    public function __construct(LoggerInterface $logger, \Services_Twilio $client, $twilioFrom, $twilioTo)
15
    {
16
        $this->logger = $logger;
17
        $this->client = $client;
18
        $this->twilioFrom = $twilioFrom;
19
        $this->twilioTo = $twilioTo;
20
    }
21
22
    public function notifyOwner($message)
23
    {
24
        try {
25
            $this->client->account->messages->sendMessage(
26
                $this->twilioFrom,
27
                $this->twilioTo,
28
                $message
29
            );
30
        } catch (\Exception $e) {
31
            $this->logger->error('Unable to send notification SMS : '.$e->getMessage());
32
        }
33
    }
34
}
35