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

Twilio::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 4
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