Skip to content

Commit 3a31238

Browse files
committed
Fixed memory leak.
1 parent bf4cb49 commit 3a31238

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Twilio.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class Twilio implements TwilioInterface
2727
* @var bool
2828
*/
2929
protected $sslVerify;
30+
31+
/**
32+
* @var \Services_Twilio
33+
*/
34+
protected $twilio;
3035

3136
/**
3237
* @param string $token
@@ -99,6 +104,10 @@ public function call($to, $message, array $options = [], $from = null)
99104
*/
100105
public function getTwilio()
101106
{
107+
if ($this->twilio) {
108+
return $this->twilio;
109+
}
110+
102111
if (!$this->sslVerify) {
103112
$http = new Services_Twilio_TinyHttp(
104113
'https://api.twilio.com',
@@ -110,8 +119,10 @@ public function getTwilio()
110119
]
111120
);
112121
}
122+
123+
$this->twilio = new Services_Twilio($this->sid, $this->token, null, isset($http) ? $http : null);
113124

114-
return new Services_Twilio($this->sid, $this->token, null, isset($http) ? $http : null);
125+
return $this->twilio;
115126
}
116127

117128
/**

0 commit comments

Comments
 (0)