Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F471323
Util.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
Util.php
View Options
<?php
abstract
class
Stripe_Util
{
public
static
function
isList
(
$array
)
{
if
(!
is_array
(
$array
))
return
false
;
// TODO: this isn't actually correct in general, but it's correct given Stripe's responses
foreach
(
array_keys
(
$array
)
as
$k
)
{
if
(!
is_numeric
(
$k
))
return
false
;
}
return
true
;
}
public
static
function
convertStripeObjectToArray
(
$values
)
{
$results
=
array
();
foreach
(
$values
as
$k
=>
$v
)
{
// FIXME: this is an encapsulation violation
if
(
Stripe_Object
::
$_permanentAttributes
->
includes
(
$k
))
{
continue
;
}
if
(
$v
instanceof
Stripe_Object
)
{
$results
[
$k
]
=
$v
->
__toArray
(
true
);
}
else
if
(
is_array
(
$v
))
{
$results
[
$k
]
=
self
::
convertStripeObjectToArray
(
$v
);
}
else
{
$results
[
$k
]
=
$v
;
}
}
return
$results
;
}
public
static
function
convertToStripeObject
(
$resp
,
$apiKey
)
{
$types
=
array
(
'charge'
=>
'Stripe_Charge'
,
'customer'
=>
'Stripe_Customer'
,
'invoice'
=>
'Stripe_Invoice'
,
'invoiceitem'
=>
'Stripe_InvoiceItem'
,
'event'
=>
'Stripe_Event'
);
if
(
self
::
isList
(
$resp
))
{
$mapped
=
array
();
foreach
(
$resp
as
$i
)
array_push
(
$mapped
,
self
::
convertToStripeObject
(
$i
,
$apiKey
));
return
$mapped
;
}
else
if
(
is_array
(
$resp
))
{
if
(
isset
(
$resp
[
'object'
])
&&
is_string
(
$resp
[
'object'
])
&&
isset
(
$types
[
$resp
[
'object'
]]))
$class
=
$types
[
$resp
[
'object'
]];
else
$class
=
'Stripe_Object'
;
return
Stripe_Object
::
scopedConstructFrom
(
$class
,
$resp
,
$apiKey
);
}
else
{
return
$resp
;
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, May 6, 2:03 PM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
82681
Default Alt Text
Util.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment