Skip to content

Commit

Permalink
Message Part: expose $partNumber (#244)
Browse files Browse the repository at this point in the history
Close #229
  • Loading branch information
wujku authored and Slamdunk committed Oct 13, 2017
1 parent 1caadd9 commit 0788d5d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
18 changes: 14 additions & 4 deletions src/Message/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ abstract class AbstractPart implements PartInterface
protected $resource;

/**
* @var null|string
* @var array
*/
protected $partNumber;
protected $parts = [];

/**
* @var array
* @var string
*/
protected $parts = [];
private $partNumber;

/**
* @var int
Expand Down Expand Up @@ -259,6 +259,16 @@ protected function getContentPartNumber(): string
return $this->partNumber;
}

/**
* Get part number.
*
* @return string
*/
final public function getPartNumber(): string
{
return $this->partNumber;
}

/**
* Get decoded part content.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Message/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public function getEmbeddedMessage(): EmbeddedMessageInterface
if (!$this->isEmbeddedMessage()) {
throw new NotEmbeddedMessageException(\sprintf(
'Attachment "%s" in message "%s" is not embedded message',
$this->partNumber,
$this->getPartNumber(),
$this->getNumber()
));
}

return new EmbeddedMessage($this->resource, $this->getNumber(), $this->partNumber, $this->getStructure()->parts[0]);
return new EmbeddedMessage($this->resource, $this->getNumber(), $this->getPartNumber(), $this->getStructure()->parts[0]);
}
}
4 changes: 2 additions & 2 deletions src/Message/EmbeddedMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function getRawHeaders(): string
public function getRawMessage(): string
{
if (null === $this->rawMessage) {
$this->rawMessage = $this->doGetContent($this->partNumber);
$this->rawMessage = $this->doGetContent($this->getPartNumber());
}

return $this->rawMessage;
Expand All @@ -71,7 +71,7 @@ public function getRawMessage(): string
*/
protected function getContentPartNumber(): string
{
$partNumber = $this->partNumber;
$partNumber = $this->getPartNumber();
if (0 === \count($this->parts)) {
$partNumber .= '.1';
}
Expand Down
7 changes: 7 additions & 0 deletions src/Message/PartInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ public function getDecodedContent(): string;
*/
public function getStructure(): \stdClass;

/**
* Get part number.
*
* @return string
*/
public function getPartNumber(): string;

/**
* Get an array of all parts for this message.
*
Expand Down

0 comments on commit 0788d5d

Please sign in to comment.