Completed
Push — master ( 45dd27...e0191e )
by PROSPER
02:00
created

Helper::correctPayload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the Jusibe PHP library.
4
 *
5
 * (c) Prosper Otemuyiwa <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Unicodeveloper\Jusibe;
12
13
use StdClass;
14
use Dotenv\Dotenv;
15
use GuzzleHttp\Client;
16
use Unicodeveloper\Jusibe\Exceptions\IsEmpty;
17
18
trait Helper {
19
20
    /**
21
    * Load Dotenv to grant getenv() access to environment variables in .env file.
22
    */
23
     public function loadEnv()
24
     {
25
         if (! getenv('APP_ENV')) {
26
             $dotenv = new Dotenv(__DIR__.'/../');
27
             $dotenv->load();
28
         }
29
     }
30
31
     /**
32
      * Get Valid Message ID
33
      * @return string
34
      */
35
     public function getValidMessageID()
36
     {
37
        return getenv('VALID_MESSAGE_ID');
38
     }
39
40
     /**
41
      * Get Invalid Message ID
42
      * @return string
43
      */
44
     public function getInvalidMessageID()
45
     {
46
        return getenv('INVALID_MESSAGE_ID');
47
     }
48
49
     /**
50
      * Get Valid Access Token
51
      * @return string
52
      */
53
     public function getValidAccessToken()
54
     {
55
        return getenv('VALID_ACCESS_TOKEN');
56
     }
57
58
     /**
59
      * Stubbed checkDeliveryStatusResponse
60
      * @return object
61
      */
62
     public function checkDeliveryStatusResponse()
63
     {
64
        $response = new StdClass;
65
        $response->message_id = $this->getValidMessageID();
66
        $response->status = 'Delivered';
67
        $response->date_sent = time();
68
        $response->date_delivered = time();
69
70
        return $response;
71
     }
72
73
     /**
74
      * Stubbed Invalid Keys Response
75
      * @return object
76
      */
77
     public function invalidKeysResponse()
78
     {
79
        $response = new StdClass;
80
        $response->error = "Invalid API Key!";
81
82
        return $response;
83
     }
84
85
     /**
86
      * Stubbed Invalid Message ID Response
87
      * @return object
88
      */
89
     public function invalidMessageIDResponse()
90
     {
91
        $response = new StdClass;
92
        $response->invalid_message_id = "Invalid message ID";
93
94
        return $response;
95
     }
96
97
     /**
98
      * Stubbed sendSMSResponse
99
      * @return object
100
      */
101
     public function sendSMSResponse()
102
     {
103
        $response = new StdClass;
104
        $response->status = 'Sent';
105
        $response->message_id = $this->getValidMessageID();
106
        $response->sms_credits_used = 1;
107
108
        return $response;
109
     }
110
111
     /**
112
      * Stubbed checkAvailableCreditsResponse
113
      * @return object
114
      */
115
     public function checkAvailableCreditsResponse()
116
     {
117
        $response = new StdClass;
118
        $response->sms_credits = 200;
119
120
        return $response;
121
     }
122
123
     /**
124
      * [correctPayload description]
125
      * @return [type] [description]
0 ignored issues
show
Documentation introduced by
The doc-type [type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
126
      */
127
     public function correctPayload()
128
     {
129
        $message  = "I LOVE YOU, BABY";
130
131
        return [
132
            'to' => '8038142771',
133
            'from' => 'TEST JUSIBE',
134
            'message' => $message
135
        ];
136
     }
137
138
     /**
139
      * Get Invalid Access Token
140
      * @return string
141
      */
142
     public function getInvalidAccessToken()
143
     {
144
        return getenv('INVALID_ACCESS_TOKEN');
145
     }
146
147
     /**
148
      * Get Valid Public Key
149
      * @return string
150
      */
151
     public function getValidPublicKey()
152
     {
153
        return getenv('VALID_PUBLIC_KEY');
154
     }
155
156
     /**
157
      * Get Valid Public Key
158
      * @return string
159
      */
160
     public function getInvalidPublicKey()
161
     {
162
        return getenv('INVALID_PUBLIC_KEY');
163
     }
164
}
165
166
167