Lines
100.00%
10 / 10
Functions and Methods
100.00%
7 / 7
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Mimepart | 100.00% | 10 / 10 | 100.00% | 7 / 7 | 12 | 100.00% | 1 / 1 | |||
| getDefaults | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 1 | |||||
| isBase64Encoded | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| isHtml | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| isText | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| isIcs | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| getContent | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| getExtension | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsentities; | |
| 4 | ||
| 5 | class Mimepart extends Schema\Entity | |
| 6 | { | |
| 7 | public const string PRIMARY = 'id'; | |
| 8 | ||
| 9 | public static $schema = "mimepart.json"; | |
| 10 | ||
| 11 | /** | |
| 12 | * @return string[] | |
| 13 | * | |
| 14 | */ | |
| 15 | #[\Override] | |
| 16 | public function getDefaults() | |
| 17 | { | |
| 18 | return [ | |
| 19 | 'mime' => '', | |
| 20 | 'content' => '', | |
| 21 | ]; | |
| 22 | } | |
| 23 | ||
| 24 | public function isBase64Encoded(): bool | |
| 25 | { | |
| 26 | return ($this->base64) ? true : false; | |
| 27 | } | |
| 28 | ||
| 29 | public function isHtml(): bool | |
| 30 | { | |
| 31 | return ($this->mime == 'text/html') ? true : false; | |
| 32 | } | |
| 33 | ||
| 34 | public function isText(): bool | |
| 35 | { | |
| 36 | return ($this->mime == 'text/plain') ? true : false; | |
| 37 | } | |
| 38 | ||
| 39 | public function isIcs(): bool | |
| 40 | { | |
| 41 | return ($this->mime == 'text/calendar') ? true : false; | |
| 42 | } | |
| 43 | ||
| 44 | public function getContent(): mixed | |
| 45 | { | |
| 46 | return ($this->isBase64Encoded()) ? \base64_decode($this->content) : $this->content; | |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * @return null|string|string[] | |
| 51 | * | |
| 52 | */ | |
| 53 | public function getExtension(): array|string|null | |
| 54 | { | |
| 55 | return preg_replace('#^.*/#', '', $this->mime); | |
| 56 | } | |
| 57 | } |