Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96196163
PartialApplicationHelper.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 23, 16:22
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 16:22 (1 d, 19 h)
Engine
blob
Format
Raw Data
Handle
23128923
Attached To
rPH Phabricator
PartialApplicationHelper.php
View Options
<?php
/**
* Helper class to wrap an object with a modified interface created by
* a partial application of its existing methods.
*
* @category Services
* @package Services_Twilio
* @author Neuman Vong <neuman@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
* @link http://pear.php.net/package/Services_Twilio
*/
class
Services_Twilio_PartialApplicationHelper
{
private
$callbacks
;
public
function
__construct
()
{
$this
->
callbacks
=
array
();
}
public
function
set
(
$method
,
$callback
,
array
$args
)
{
if
(!
is_callable
(
$callback
))
{
return
FALSE
;
}
$this
->
callbacks
[
$method
]
=
array
(
$callback
,
$args
);
}
public
function
__call
(
$method
,
$args
)
{
if
(!
isset
(
$this
->
callbacks
[
$method
]))
{
throw
new
Exception
(
"Method not found: $method"
);
}
list
(
$callback
,
$cb_args
)
=
$this
->
callbacks
[
$method
];
return
call_user_func_array
(
$callback
,
array_merge
(
$cb_args
,
$args
)
);
}
}
Event Timeline
Log In to Comment