GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( f25603...2d0cfb )
by Lester
01:10
created

SendHttpApiParams::getFormattedMobile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace LBHurtado\EngageSpark\Classes;
4
5
use Illuminate\Support\Arr;
6
use LBHurtado\EngageSpark\EngageSpark;
7
use Propaganistas\LaravelPhone\PhoneNumber;
8
use LBHurtado\Common\Contracts\HttpApiParams;
9
10
class SendHttpApiParams implements HttpApiParams
11
{
12
    /**
13
     * @var EngageSpark
14
     */
15
    protected $service;
16
17
    /**
18
     * @var string
19
     */
20
    protected $mobile;
21
22
    /**
23
     * @var string
24
     */
25
    protected $message;
26
27
    /**
28
     * @var string
29
     */
30
    protected $senderId;
31
32
    /**
33
     * @var string
34
     */
35
    protected $recipientType = 'mobile_number';
36
37
    /**
38
     * SendParams constructor.
39
     * @param $service
40
     * @param $mobile
41
     * @param $message
42
     */
43
    public function __construct(EngageSpark $service, string $mobile, string $message, string $senderId = null)
44
    {
45
        $this->service = $service;
46
        $this->mobile = $mobile;
47
        $this->message = $message;
48
        $this->setSenderId($service, $senderId);
49
    }
50
51
    public function toArray(): array
52
    {
53
        return [
54
            'orgId' => $this->service->getOrgId(),
55
            'to' => $this->getFormattedMobile(),
56
            'from' => $this->senderId,
57
            'message' => $this->message,
58
        ];
59
    }
60
61
    protected function setSenderId(EngageSpark $service, string $senderId = null)
62
    {
63
        $this->senderId = $senderId ?? $service->getSenderId();
64
65
        return $this;
66
    }
67
68
    protected function getFormattedMobile()
69
    {
70
        return tap(PhoneNumber::make($this->mobile, 'PH')->formatE164(), function(&$recipient) {
71
            $recipient = preg_replace('/\D/', '', $recipient);
72
        });
73
    }
74
}
75