SoapClient large refactoring & tests update
This commit is contained in:
60
src/BeSimple/SoapCommon/Mime/Parser/ParsedPartList.php
Normal file
60
src/BeSimple/SoapCommon/Mime/Parser/ParsedPartList.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace BeSimple\SoapCommon\Mime\Parser;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ParsedPartList
|
||||
{
|
||||
private $parts;
|
||||
|
||||
/**
|
||||
* @param ParsedPart[] $parts
|
||||
*/
|
||||
public function __construct(array $parts)
|
||||
{
|
||||
$this->parts = $parts;
|
||||
}
|
||||
|
||||
public function getMainPartCount()
|
||||
{
|
||||
$mainPartsCount = 0;
|
||||
foreach ($this->getParts() as $parsedPart) {
|
||||
if ($parsedPart->isMain() === true) {
|
||||
$mainPartsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return $mainPartsCount;
|
||||
}
|
||||
|
||||
public function hasExactlyOneMainPart()
|
||||
{
|
||||
return $this->getMainPartCount() === 1;
|
||||
}
|
||||
|
||||
public function getPartContentIds()
|
||||
{
|
||||
$partContentIds = [];
|
||||
foreach ($this->getParts() as $parsedPart) {
|
||||
$partContentIds[] = $parsedPart->getPart()->getContentId();
|
||||
}
|
||||
|
||||
return $partContentIds;
|
||||
}
|
||||
|
||||
public function getParts()
|
||||
{
|
||||
return $this->parts;
|
||||
}
|
||||
|
||||
public function getPartCount()
|
||||
{
|
||||
return count($this->parts);
|
||||
}
|
||||
|
||||
public function hasParts()
|
||||
{
|
||||
return $this->getPartCount() > 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user