refactor: message object properties
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -32,9 +32,9 @@ abstract class MessagePartBaseAbstract implements MessagePartInterface {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array &$data Reference to data array
|
||||
* @param array|null &$data Reference to data array
|
||||
*/
|
||||
public function __construct(array &$data = null) {
|
||||
public function __construct(array|null &$data = null) {
|
||||
if ($data === null) {
|
||||
$data = [];
|
||||
}
|
||||
@@ -52,49 +52,70 @@ abstract class MessagePartBaseAbstract implements MessagePartInterface {
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getId(): ?string {
|
||||
return $this->data['partId'] ?? null;
|
||||
return $this->data[MessagePartInterface::PROPERTY_PART_ID] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSize(): ?int {
|
||||
return $this->data[MessagePartInterface::PROPERTY_SIZE] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): ?string {
|
||||
return $this->data['type'] ?? null;
|
||||
return $this->data[MessagePartInterface::PROPERTY_TYPE] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDisposition(): ?string {
|
||||
return $this->data['disposition'] ?? null;
|
||||
return $this->data[MessagePartInterface::PROPERTY_DISPOSITION] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName(): ?string {
|
||||
return $this->data['name'] ?? null;
|
||||
return $this->data[MessagePartInterface::PROPERTY_NAME] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCharset(): ?string {
|
||||
return $this->data['charset'] ?? null;
|
||||
return $this->data[MessagePartInterface::PROPERTY_CHARSET] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getContentId(): ?string {
|
||||
return $this->data[MessagePartInterface::PROPERTY_CONTENT_ID] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLanguage(): ?string {
|
||||
return $this->data['language'] ?? null;
|
||||
return $this->data[MessagePartInterface::PROPERTY_LANGUAGE] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLocation(): ?string {
|
||||
return $this->data['location'] ?? null;
|
||||
return $this->data[MessagePartInterface::PROPERTY_LOCATION] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getContent(): ?string {
|
||||
return $this->data[MessagePartInterface::PROPERTY_CONTENT] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,9 +132,9 @@ abstract class MessagePartBaseAbstract implements MessagePartInterface {
|
||||
$result = $this->data;
|
||||
|
||||
if (!empty($this->parts)) {
|
||||
$result['subParts'] = [];
|
||||
$result[MessagePartInterface::PROPERTY_SUB_PARTS] = [];
|
||||
foreach ($this->parts as $part) {
|
||||
$result['subParts'][] = $part->jsonSerialize();
|
||||
$result[MessagePartInterface::PROPERTY_SUB_PARTS][] = $part->jsonSerialize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user