SoapClient large refactoring & tests update
This commit is contained in:
33
src/BeSimple/SoapCommon/Mime/PartFactory.php
Normal file
33
src/BeSimple/SoapCommon/Mime/PartFactory.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace BeSimple\SoapCommon\Mime;
|
||||
|
||||
use BeSimple\SoapBundle\Soap\SoapAttachment;
|
||||
|
||||
class PartFactory
|
||||
{
|
||||
public static function createFromSoapAttachment(SoapAttachment $attachment)
|
||||
{
|
||||
return new Part(
|
||||
$attachment->getContent(),
|
||||
Part::CONTENT_TYPE_PDF,
|
||||
Part::CHARSET_UTF8,
|
||||
Part::ENCODING_BINARY,
|
||||
$attachment->getId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SoapAttachment[] $attachments SOAP attachments
|
||||
* @return Part[]
|
||||
*/
|
||||
public static function createAttachmentParts(array $attachments = [])
|
||||
{
|
||||
$parts = [];
|
||||
foreach ($attachments as $attachment) {
|
||||
$parts[] = self::createFromSoapAttachment($attachment);
|
||||
}
|
||||
|
||||
return $parts;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user