Completed
Push — master ( 0257d4...45dd27 )
by PROSPER
02:03
created

Helper::invalidKeysResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
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 sendSMSResponse
87
      * @return object
88
      */
89
     public function sendSMSResponse()
90
     {
91
        $response = new StdClass;
92
        $response->status = 'Sent';
93
        $response->message_id = $this->getValidMessageID();
94
        $response->sms_credits_used = 1;
95
96
        return $response;
97
     }
98
99
     /**
100
      * Stubbed checkAvailableCreditsResponse
101
      * @return object
102
      */
103
     public function checkAvailableCreditsResponse()
104
     {
105
        $response = new StdClass;
106
        $response->sms_credits = 200;
107
108
        return $response;
109
     }
110
111
     /**
112
      * [correctPayload description]
113
      * @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...
114
      */
115
     public function correctPayload()
116
     {
117
        $message  = "I LOVE YOU, BABY";
118
119
        return [
120
            'to' => '8038142771',
121
            'from' => 'TEST JUSIBE',
122
            'message' => $message
123
        ];
124
     }
125
126
     /**
127
      * Get Invalid Access Token
128
      * @return string
129
      */
130
     public function getInvalidAccessToken()
131
     {
132
        return getenv('INVALID_ACCESS_TOKEN');
133
     }
134
135
     /**
136
      * Get Valid Public Key
137
      * @return string
138
      */
139
     public function getValidPublicKey()
140
     {
141
        return getenv('VALID_PUBLIC_KEY');
142
     }
143
144
     /**
145
      * Get Valid Public Key
146
      * @return string
147
      */
148
     public function getInvalidPublicKey()
149
     {
150
        return getenv('INVALID_PUBLIC_KEY');
151
     }
152
}
153
154
155