-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from josemmo/develop
v0.1.3
- Loading branch information
Showing
12 changed files
with
425 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?php | ||
namespace Einvoicing; | ||
|
||
class Attachment { | ||
protected $id = null; | ||
protected $description = null; | ||
protected $externalUrl = null; | ||
protected $filename = null; | ||
protected $mimeCode = null; | ||
protected $contents = null; | ||
|
||
/** | ||
* Get attachment ID | ||
* @return Identifier|null Attachment ID | ||
*/ | ||
public function getId(): ?Identifier { | ||
return $this->id; | ||
} | ||
|
||
|
||
/** | ||
* Set attachment ID | ||
* @param Identifier|null $id Attachment ID | ||
* @return self Attachment instance | ||
*/ | ||
public function setId(?Identifier $id): self { | ||
$this->id = $id; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Get description | ||
* @return string|null Attachment description | ||
*/ | ||
public function getDescription(): ?string { | ||
return $this->description; | ||
} | ||
|
||
|
||
/** | ||
* Set description | ||
* @param string|null $description Attachment description | ||
* @return self Attachment instance | ||
*/ | ||
public function setDescription(?string $description): self { | ||
$this->description = $description; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Has external URL | ||
* @return boolean Whether this attachment has an external URL or not | ||
*/ | ||
public function hasExternalUrl(): bool { | ||
return ($this->externalUrl !== null); | ||
} | ||
|
||
|
||
/** | ||
* Get external URL | ||
* @return string|null Attachment external URL | ||
*/ | ||
public function getExternalUrl(): ?string { | ||
return $this->externalUrl; | ||
} | ||
|
||
|
||
/** | ||
* Set external URL | ||
* @param string|null $externalUrl Attachment external URL | ||
* @return self Attachment instance | ||
*/ | ||
public function setExternalUrl(?string $externalUrl): self { | ||
$this->externalUrl = $externalUrl; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Get filename | ||
* @return string|null Attachment filename | ||
*/ | ||
public function getFilename(): ?string { | ||
return $this->filename; | ||
} | ||
|
||
|
||
/** | ||
* Set filename | ||
* @param string|null $filename Attachment filename | ||
* @return self Attachment instance | ||
*/ | ||
public function setFilename(?string $filename): self { | ||
$this->filename = $filename; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Get mime code | ||
* @return string|null Attachment mime code | ||
*/ | ||
public function getMimeCode(): ?string { | ||
return $this->mimeCode; | ||
} | ||
|
||
|
||
/** | ||
* Set mime code | ||
* @param string|null $mimeCode Attachment mime code | ||
* @return self Attachment instance | ||
*/ | ||
public function setMimeCode(?string $mimeCode): self { | ||
$this->mimeCode = $mimeCode; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Has embedded contents | ||
* @return boolean Whether this attachment has embedded contents or not | ||
*/ | ||
public function hasContents(): bool { | ||
return ($this->contents !== null); | ||
} | ||
|
||
|
||
/** | ||
* Get embedded contents | ||
* @return string|null Attachment contents | ||
*/ | ||
public function getContents(): ?string { | ||
return $this->contents; | ||
} | ||
|
||
|
||
/** | ||
* Set embedded contents | ||
* @param string|null $content Attachment contents | ||
* @return self Attachment instance | ||
*/ | ||
public function setContents(?string $contents): self { | ||
$this->contents = $contents; | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
namespace Einvoicing\Traits; | ||
|
||
use Einvoicing\Attachment; | ||
use OutOfBoundsException; | ||
|
||
trait AttachmentsTrait { | ||
protected $attachments = []; | ||
|
||
/** | ||
* Get attachments | ||
* @return Attachment[] Array of attachments | ||
*/ | ||
public function getAttachments(): array { | ||
return $this->attachments; | ||
} | ||
|
||
|
||
/** | ||
* Add attachment | ||
* @param Attachment $attachment Attachment | ||
* @return self This instance | ||
*/ | ||
public function addAttachment(Attachment $attachment): self { | ||
$this->attachments[] = $attachment; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Remove attachment | ||
* @param int $index Attachment index | ||
* @return self This instance | ||
* @throws OutOfBoundsException if attachment index is out of bounds | ||
*/ | ||
public function removeAttachment(int $index): self { | ||
if ($index < 0 || $index >= count($this->attachments)) { | ||
throw new OutOfBoundsException('Could not find attachment by index'); | ||
} | ||
array_splice($this->attachments, $index, 1); | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Clear all attachments | ||
* @return self This instance | ||
*/ | ||
public function clearAttachments(): self { | ||
$this->attachments = []; | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.