Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
51318946
Unverified
Commit
51318946
authored
Aug 27, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimise method to set up request params.
parent
32d1fed0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
17 deletions
+13
-17
Request.php
src/Request.php
+13
-17
No files found.
src/Request.php
View file @
51318946
...
...
@@ -166,32 +166,28 @@ class Request
/**
* Properly set up the request params
*
* If any item of the array is a resource, reformat it to a multipart request.
* Else, just return the passed data as form params.
*
* @param array $data
*
* @return array
*/
private
static
function
setUpRequestParams
(
array
$data
)
{
//Check for resources in data
$contains_resource
=
false
;
foreach
(
$data
as
$item
)
{
if
(
is_resource
(
$item
))
{
$contains_resource
=
true
;
break
;
}
}
$has_resource
=
false
;
$multipart
=
[];
$request_params
=
[];
//Reformat data array in multipart way
if
(
$contains_resource
)
{
foreach
(
$data
as
$key
=>
$item
)
{
$request_params
[
'multipart'
][]
=
[
'name'
=>
$key
,
'contents'
=>
$item
];
}
}
else
{
$request_params
[
'form_params'
]
=
$data
;
//Reformat data array in multipart way if it contains a resource
foreach
(
$data
as
$key
=>
$item
)
{
$has_resource
|=
is_resource
(
$item
);
$multipart
[]
=
[
'name'
=>
$key
,
'contents'
=>
$item
];
}
if
(
$has_resource
)
{
return
[
'multipart'
=>
$multipart
];
}
return
$request_params
;
return
[
'form_params'
=>
$data
]
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment