Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
encodeByteStream example
return
$this
->
getEncoder
(
)
->
encodeString
(
$this
->
getBody
(
)
,
$this
->charset
)
;
}
public
function
bodyToIterable
(
)
: iterable
{
if
(
$this
->body instanceof File
)
{
$path
=
$this
->body->
getPath
(
)
;
if
(
false ===
$handle
= @
fopen
(
$path
, 'r', false
)
)
{
throw
new
InvalidArgumentException
(
sprintf
(
'Unable to open path "%s".',
$path
)
)
;
}
yield from
$this
->
getEncoder
(
)
->
encodeByteStream
(
$handle
)
;
}
elseif
(
null !==
$this
->seekable
)
{
if
(
$this
->seekable
)
{
rewind
(
$this
->body
)
;
}
yield from
$this
->
getEncoder
(
)
->
encodeByteStream
(
$this
->body
)
;
}
else
{
yield
$this
->
getEncoder
(
)
->
encodeString
(
$this
->body
)
;
}
}
public
function
getPreparedHeaders
(
)
: Headers
{
return
$this
->
getEncoder
(
)
->
encodeString
(
$this
->
getBody
(
)
,
$this
->charset
)
;
}
public
function
bodyToIterable
(
)
: iterable
{
if
(
$this
->body instanceof File
)
{
$path
=
$this
->body->
getPath
(
)
;
if
(
false ===
$handle
= @
fopen
(
$path
, 'r', false
)
)
{
throw
new
InvalidArgumentException
(
sprintf
(
'Unable to open path "%s".',
$path
)
)
;
}
yield from
$this
->
getEncoder
(
)
->
encodeByteStream
(
$handle
)
;
}
elseif
(
null !==
$this
->seekable
)
{
if
(
$this
->seekable
)
{
rewind
(
$this
->body
)
;
}
yield from
$this
->
getEncoder
(
)
->
encodeByteStream
(
$this
->body
)
;
}
else
{
yield
$this
->
getEncoder
(
)
->
encodeString
(
$this
->body
)
;
}
}
public
function
getPreparedHeaders
(
)
: Headers
{